Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Pedroalves

Tabela dinamica

Recommended Posts

como faço uma pesquisa dinamica de modo a adicionar numa tabela

e numero de linhas vai aumentando conforme vou pondo dados tabela

Compartilhar este post


Link para o post
Compartilhar em outros sites

Acho que entendi...

Bom... você terá que verificar qual a primeira linha da tabela 'disponível' e carregar os dados via Ajax.

 

Para incrementar as linhas, facilita se você usar jQuery:

var $table = $('table#ID_DA_TABELA');
var $new = $('tr:last-child', $table).clone(true);
$new.find('input, select, textarea').empty();
$table.append($new);

Compartilhar este post


Link para o post
Compartilhar em outros sites

não estou a conseguir

segue-se o codigo

<?php require_once('../Connections/ola.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "2";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../CLIENTES/cliente_index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE vendas SET id_fornecedor=%s WHERE `Data`=%s",
                       GetSQLValueString($_POST['ID'], "int"),
                       GetSQLValueString($_POST['text1'], "date"));

  mysql_select_db($database_ola, $ola);
  $Result1 = mysql_query($updateSQL, $ola) or die(mysql_error());

  $updateGoTo = "confirmar.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$joindate=date("y-m-d h-m-s");
$month=substr ($joindate,5,2);
$date=substr($joindate,8,2);
$year=substr($joindate,0,4);
$hour=substr($joindate,11,2);
$minutes=substr($joindate,14,2);
$seconds=substr($joindate,17,4);
mysql_select_db($database_ola, $ola);
$query_Recordset1 = "SELECT Username FROM `user` where Username='".$_SESSION['MM_Username']."'";
$Recordset1 = mysql_query($query_Recordset1, $ola) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_ola, $ola);
$query_Recordset2 = "SELECT user.tipo,tipo.NOME FROM user  INNER JOIN tipo ON tipo.id_tipo =user.tipo WHERE user.Username='".$_SESSION['MM_Username']."' ";
$Recordset2 = mysql_query($query_Recordset2, $ola) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

$colname_Recordset3 = "-1";
if (isset($_GET['id'])) {
  $colname_Recordset3 = $_GET['id'];
}
mysql_select_db($database_ola, $ola);
$query_Recordset3 = sprintf("SELECT * FROM fornecedores WHERE id_fornecedor = %s", GetSQLValueString($colname_Recordset3, "int"));
$Recordset3 = mysql_query($query_Recordset3, $ola) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);

$soma=1+1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
#apDiv1 {
    position:absolute;
    width:1251px;
    height:68px;
    z-index:1;
    left: 0;
    top: 0;
    text-align: center;
    font-size: xx-large;
}
#apDiv2 {
    position:absolute;
    left:832px;
    top:77px;
    width:389px;
    height:222px;
    z-index:2;
    text-align: center;
}
</style>
<script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<style type="text/css">
#apDiv3 {
    position:absolute;
    left:0px;
    top:76px;
    width:131px;
    height:500px;
    z-index:3;
}
</style>
<style type="text/css">
#apDiv4 {
    position:absolute;
    left:0px;
    top:69px;
    width:1248px;
    height:768px;
    z-index:4;
    text-align: center;
}
#apDiv5 {
    position:absolute;
    left:3px;
    top:836px;
    width:1242px;
    height:29px;
    z-index:5;
    text-align: center;
    font-weight: bold;
}
#apDiv6 {
    position:absolute;
    left:8px;
    top:186px;
    width:1378px;
    height:37px;
    z-index:6;
}
</style>
<link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#apDiv7 {
    position:absolute;
    left:2px;
    top:106px;
    width:208px;
    height:55px;
    z-index:6;
}
#apDiv8 {
    position:absolute;
    left:2px;
    top:163px;
    width:208px;
    height:25px;
    z-index:7;
}
#apDiv9 {
    position:absolute;
    left:1px;
    top:190px;
    width:213px;
    height:468px;
    z-index:8;
}
</style>
<link href="../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#apDiv10 {
    position:absolute;
    left:413px;
    top:334px;
    width:836px;
    height:327px;
    z-index:9;
    text-align: center;
}
</style>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="apDiv1">
  <p>GESTSTOCKS</p>
</div>
<div id="apDiv4">
  <ul id="MenuBar1" class="MenuBarHorizontal">
    <li><a href="../logout.php">LOGOUT</a>    </li>
    <li><a class="MenuBarItemSubmenu" href="#">AREA FINANCEIRA</a>
      <ul>
        <li><a class="MenuBarItemSubmenu" href="#">COMPRAS</a>
          <ul>
<li><a href="#">LISTAR COMPRA</a></li>
            <li><a href="#">ALTERAR COMPRA</a></li>
            <li><a href="#">ELIMINAR COMPRA</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">VENDAS</a>
          <ul>
<li><a href="#">NOVA FACTURA</a></li>
<li><a href="#">NOVO RECIBO</a></li>
<li><a href="#">NOVA VENDA A DINHEIRO</a></li>
<li><a href="#">ALTERAR FACTURA</a></li>
<li><a href="#">ALTERAR RECIBO</a></li>
<li><a href="#">ALTERAR VENDA A DINHEIRO</a></li>
<li><a href="#">LISTAR FACTURA</a></li>
<li><a href="#">LISTAR RECIBO</a></li>
<li><a href="#">LISTAR VENDA A DINHEIRO</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">PRODUTOS</a>
          <ul>

            <li><a href="#">ALTERAR</a></li>
<li><a href="#">ELIMINAR</a></li>
            <li><a href="pesquisa_produto.php">PROCURAR</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">HISTORIAL</a>
          <ul>
            <li><a href="#"> VENDAS</a></li>
            <li><a href="#"> COMPRAS</a></li>
            <li><a href="#">TOTAL</a></li>
          </ul>
        </li>
      </ul>
    </li>
    <li><a href="#" class="MenuBarItemSubmenu">CLIENTES</a>
      <ul>
        <li><a href="#">NOVO CLIENTE</a></li>
        <li><a href="#">ALTERAR DADOS</a></li>
        <li><a href="#" class="MenuBarItemSubmenu">LISTAR CLIENTE</a>
          <ul>
            <li><a href="#">HISTORICO DO CLIENTE</a></li>
          </ul>
        </li>
      </ul>
    </li>
    <li><a href="#" class="MenuBarItemSubmenu">FORNECEDORES</a>
      <ul>
<li><a href="#">NOVO FORNECEDOR</a></li>
<li><a href="#">ALTERAR DADOS</a></li>
<li><a href="#">LISTAR FORNECEDOR</a></li>
<li><a href="#">ELIMINAR FORNECEDOR</a></li>
      </ul>
    </li>
    <li><a href="#" class="MenuBarItemSubmenu">RECLAMAÇÕES</a>
      <ul>
        <li><a href="#">VER RECLAMAÇÕES</a></li>
      </ul>
    </li>
    <li><a href="#" class="MenuBarItemSubmenu">OPÇÕES</a>
      <ul>
        <li><a href="#">ALTERAR DADOS</a></li>
        <li><a href="#">MUDAR PASSWORD</a></li>
      </ul>
    </li>
  </ul>
  <p> </p>
  <p> NOVA COMPRA</p>
  <p> </p>
  <p> </p>
</div>
<div id="apDiv5">COPYRIGHT PEDRO ALVES</div>
<div id="apDiv7">
  <p>NOME:  <?php echo $row_Recordset1['Username']; ?></p>
</div>
<div id="apDiv8">TIPO:  <?php echo $row_Recordset2['NOME']; ?></div>
<div id="apDiv9">
  <ul id="MenuBar2" class="MenuBarVertical">
    <li><a href="funcionario_index.php">PAGINA PRINCIPAL</a></li>
    <li><a class="MenuBarItemSubmenu" href="#">HORARIO</a>
      <ul>
        <li><a href="#">VER HORARIO</a></li>
        <li><a href="#">ALTERAR HORARIO</a></li>
      </ul>
    </li>
    <li><a href="#" class="MenuBarItemSubmenu">SOBRE A EMPRESA</a>
      <ul>
    <li><a href="#">VER SOBRE A EMPRESA</a></li>
  </ul>
</li>
    <li><a href="#" class="MenuBarItemSubmenu">MENSAGENS</a>
      <ul>
        <li><a href="#">ENVIAR MENSAGEM</a></li>
        <li><a href="#">LISTAR MENSAGEM</a></li>
        <li><a href="#">RASCUNHOS</a></li>
<li><a href="#">ELIMINAR MENSAGEM</a></li>
      </ul>
    </li>
  </ul>
</div>
<div id="apDiv10"><script src="../Javascript/jquery.js"></script>
<script>
        $(document).ready(function(){
                $("input[name='suggest']").keyup(function(){
                        createList('.suggest');
                        $.ajax({
                                type: "GET",//apenas pra ficar mais fácil de debugar, pode mudar para POST depois
                                url: "function.php",
                                data: "parte="+$(this).val(),
                                success: function( data ){
                                        $("#suggest").html( data );
                                }
                        });
                });

                $("#suggest a").live('click', function( e ){
                        e.preventDefault();
                        var href = $(this).attr('href');
                        var id = href.split('=');

                        $("input[name='id']").val( id[1] );
                        $("input[name='nome']").val( $(this).text() );

                        $("#suggest").remove();
                });
                $("#suggest").mouseout(function(){
                        $("#suggest").remove();
                });
        });
        function createList( el )
        {
                $("#suggest").remove();

                var list = document.createElement('ul');
                list.id = 'suggest';
                $( el ).append( list );
        }
</script>

  <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
    DATA
  <span id="sprytextfield1">
      <label for="text1"></label>
      <input name="text1" type="text" id="text1" value="<?php  echo $joindate=date("y-m-d");?>" size="8" readonly="readonly" />
      <br />
      <br />
<fieldset>
</fieldset>
      
      <span class="textfieldRequiredMsg">A value is required.</span></span>
    
    <p>
      
    </p>
    <p>
      <label class="suggest">Nome
        <input type="text" name="suggest" />
      </label>
      <label for="id">ID</label>
      <input name="id" type="text" id="id" readonly="readonly" />
      <label>Nome:
        <input name="nome" type="text" readonly="readonly" />
      <label>Preço:
        <input name="preco" type="text" readonly="readonly" />
      </label>
      <script src="../Javascript/jquery.js"></script>
<script>
        $(document).ready(function(){
                $("input[name='suggest']").keyup(function(){
                        createList('.suggest');
                        $.ajax({
                                type: "GET",//apenas pra ficar mais fácil de debugar, pode mudar para POST depois
                                url: "Pesquisaproduto.php",
                                data: "parte="+$(this).val(),
                                success: function( data ){
                                        $("#suggest").html( data );
                                }
                        });
                });

                $("#suggest a").live('click', function( e ){
                        e.preventDefault();
                        var href = $(this).attr('href');
                        var id = href.split('=');

                        $("input[name='id']").val( id[1] );
                        $("input[name='nome']").val( $(this).text() );
                        //$("input[name='preco']").val( id[1] );

                        $("#suggest").remove();
                });
                $("#suggest").mouseout(function(){
                        $("#suggest").remove();
                });
        });
        function createList( el )
        {
                $("#suggest").remove();

                var list = document.createElement('ul');
                list.id = 'suggest';
                $( el ).append( list );
        }
</script>
      <script src="../Javascript/111.js"></script>
<link href="estiloSistema.css" rel="stylesheet" type="text/css">

<input type="reset" name="button2" id="button2" value="ACEITAR" />

<body topmargin="0" leftmargin="0">
<script>

var ArrayLetras = new Array( 8 );
ArrayLetras[0] = " ";
ArrayLetras[1] = "Código";
ArrayLetras[2] = "Descrição";
ArrayLetras[3] = "Quantidade";
ArrayLetras[4] = "Preço sem iva";
ArrayLetras[5] = "Iva";
ArrayLetras[6] = "Valor do Iva";
ArrayLetras[7] = "Preço com iva";

var linhas = 10;
var colunas = 7;
var letras = 8;
var tamanho = ArrayLetras.length;

document.write( "<table border='1' id='grid' cellpadding='2' cellspacing='0' id='tabela' width='100%' bordercolor='#ffffff'>");
document.write( "<tr bordercolordark='#c0c0c0' bordercolorlight='#c0c0c0'>" );

for( i = 0; i < letras; i ++ ) {
document.write( "<td bgcolor='#e2e2e2' align='center' class='textoBusca'>"+ArrayLetras[i]+"</td>" );
}

document.write( "</tr>" );

for( i = 1; i < linhas; i ++ ) {

document.write( "<tr bordercolordark='#e2e2e2' bordercolorlight='#e2e2e2'>" );
document.write( "<td width='3%' bgcolor='#e2e2e2' align='center' class='textoBusca'>"+i+"</td>" );

for( j = 0; j < colunas; j ++ ) {
document.write( "<td align='center'><input id="+ArrayLetras[j+1]+i+" type='text' size='35' onblur='java script:mostraCelula( id, this.value );' class='form'></td>" );
}
}

document.write( "</tr>" );
document.write( "</table>" );

</script>
<p> </p>
<label for="textfield">VALOR TOTAL</label>
</p>
  <span id="sprytextfield2">
  <label for="text2"></label>
  <input name="text2" type="text" id="text2" value="<?php echo $soma?>" readonly="readonly" />
  <span class="textfieldRequiredMsg">A value is required.</span></span>
  <p>
    <input type="submit" name="button" id="button" value="FINALIZAR COMPRA" />
  </p>
  <input type="hidden" name="MM_update" value="form1" />
  </form>
</div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
</script>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset2);

mysql_free_result($Recordset3);
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

outro script meu feito de frankstein...

 

cara, comece do zero.

apague toda essa bagunça do dreamweaver ai, e recomece.

Compartilhar este post


Link para o post
Compartilhar em outros sites

não é possivel ver onde esta o erro sem ter que apagar todo o codigo

o meu problema é na tabela

mas o resto esta a funcionar correctamente

Compartilhar este post


Link para o post
Compartilhar em outros sites

<script src="../Javascript/111.js"></script>

<link href="estiloSistema.css" rel="stylesheet" type="text/css">

 

<input type="reset" name="button2" id="button2" value="ACEITAR" />

 

<body topmargin="0" leftmargin="0">

<script>

 

var ArrayLetras = new Array( 8 );

ArrayLetras[0] = " ";

ArrayLetras[1] = "Código";

ArrayLetras[2] = "Descrição";

ArrayLetras[3] = "Quantidade";

ArrayLetras[4] = "Preço sem iva";

ArrayLetras[5] = "Iva";

ArrayLetras[6] = "Valor do Iva";

ArrayLetras[7] = "Preço com iva";

 

var linhas = 10;

var colunas = 7;

var letras = 8;

var tamanho = ArrayLetras.length;

 

document.write( "<table border='1' id='grid' cellpadding='2' cellspacing='0' id='tabela' width='100%' bordercolor='#ffffff'>");

document.write( "<tr bordercolordark='#c0c0c0' bordercolorlight='#c0c0c0'>" );

 

for( i = 0; i < letras; i ++ ) {

document.write( "<td bgcolor='#e2e2e2' align='center' class='textoBusca'>"+ArrayLetras+"</td>" );

}

 

document.write( "</tr>" );

 

for( i = 1; i < linhas; i ++ ) {

 

document.write( "<tr bordercolordark='#e2e2e2' bordercolorlight='#e2e2e2'>" );

document.write( "<td width='3%' bgcolor='#e2e2e2' align='center' class='textoBusca'>"+i+"</td>" );

 

for( j = 0; j < colunas; j ++ ) {

document.write( "<td align='center'><input id="+ArrayLetras[j+1]+i+" type='text' size='35' onblur='java script:mostraCelula( id, this.value );' class='form'></td>" );

}

}

 

document.write( "</tr>" );

document.write( "</table>" );

 

</script>

o meu problema esta neste codigo aqui

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.