Jump to content


Photo

Text Field Nao Funciona Com Repeat Region


  • Faça o login para participar
Nenhuma resposta neste tópico

#1 AlexCardoso

AlexCardoso

    Novato no fórum

  • Usuários
  • 9 posts
  • Sexo:Não informado

Posted 05/11/2009, 21:05

Pessoal, to precisando de uma ajuda, ja procurei em todos lugares mas nao achei a resposta,
é o seguinte:
Tenho uma tabela com o nome, preço e quantidade, a coluna quantidade é um text field, para a pessoa colocar a quantidade que quer do produto, mas quando eu dou um repeat region na linha, funciona quase tudo certo, só a parte da quantidade com text field que nao funciona, ele só atualiza a quantidade do primeiro produto, mas quando eu faço um repeat region da tabela toda funciona normal, mas dando um repeat da tabela fica estranho, queria que só os produtos repetissem nao a tabela toda, mas tem esse problema do repeat do text field.
Quem puder ajudar agradeço...
Abaixo o codigo
[codebox]<?php require_once('Connections/macfrutas.php'); ?>

<?php
// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_macfrutas = new KT_connection($macfrutas, $database_macfrutas);

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_macfrutas, "");
//Grand Levels: Level
$restrict->addLevel("cliente");
$restrict->Execute();
//End Restrict Access To Page

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_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO pedido_cliente (nome, preco, embalagem, quantidade) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['preco'], "double"),
GetSQLValueString($_POST['embalagem'], "text"),
GetSQLValueString($_POST['quantidade'], "text"));

mysql_select_db($database_macfrutas, $macfrutas);
$Result1 = mysql_query($insertSQL, $macfrutas) or die(mysql_error());
}

mysql_select_db($database_macfrutas, $macfrutas);
$query_listaprod = "SELECT * FROM produtos";
$listaprod = mysql_query($query_listaprod, $macfrutas) or die(mysql_error());
$row_listaprod = mysql_fetch_assoc($listaprod);
$totalRows_listaprod = mysql_num_rows($listaprod);

mysql_select_db($database_macfrutas, $macfrutas);
$query_soma = "SELECT (quantidade*preco)as somaitem, sum(preco*quantidade)as somatotal FROM pedido_cliente";
$soma = mysql_query($query_soma, $macfrutas) or die(mysql_error());
$row_soma = mysql_fetch_assoc($soma);
$totalRows_soma = mysql_num_rows($soma);

mysql_select_db($database_macfrutas, $macfrutas);
$query_listaresultado = "SELECT *,(quantidade*preco) as total FROM pedido_cliente ";
$listaresultado = mysql_query($query_listaresultado, $macfrutas) or die(mysql_error());
$row_listaresultado = mysql_fetch_assoc($listaresultado);
$totalRows_listaresultado = mysql_num_rows($listaresultado);

mysql_select_db($database_macfrutas, $macfrutas);
$query_sessao = "SELECT sessao FROM pedido_cliente";
$sessao = mysql_query($query_sessao, $macfrutas) or die(mysql_error());
$row_sessao = mysql_fetch_assoc($sessao);
$totalRows_sessao = mysql_num_rows($sessao);

// Make a logout transaction instance
$logoutTransaction = new tNG_logoutTransaction($conn_macfrutas);
$tNGs->addTransaction($logoutTransaction);
// Register triggers
$logoutTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "GET", "KT_logout_now");
$logoutTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "index.php");
// Add columns
// End of logout transaction instance

// Make an instance of the transaction object
$del_pedido_cliente = new tNG_delete($conn_macfrutas);
$tNGs->addTransaction($del_pedido_cliente);
// Register triggers
$del_pedido_cliente->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "GET", "delete");
$del_pedido_cliente->registerTrigger("END", "Trigger_Default_Redirect", 99, "index.php?pagina=cliente");
// Add columns
$del_pedido_cliente->setTable("pedido_cliente");
$del_pedido_cliente->setPrimaryKey("pedido_id", "NUMERIC_TYPE", "GET", "del");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);

// Initialize the Alternate Color counter
$ac_sw1 = 0;

// Initialize the Alternate Color counter
$ac_sw2 = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<link rel="stylesheet" type="text/css" href="css/cliente.css"/>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mac Frutas</title>
</head>

<body>
<h3><strong>Voce está logado como : <?php echo $_SESSION['kt_login_user']; ?> </strong><br />
<a href="<?php echo $logoutTransaction->getLogoutLink(); ?>">Sair do sistema</a>
</h3>
<form name="form" action="<?php echo $editFormAction; ?>" method="POST">
<table width="765" border="0" cellpadding="2">
<tr>
<td width="150"><strong>Nome</strong></td>
<td width="134"><strong>Pre&ccedil;o</strong></td>
<td width="145"><strong>Embalagem</strong></td>
<td width="69"><strong>Quantidade</strong></td>
<td width="112"><strong>Colocar no pedido</strong></td>
</tr>
<?php do { ?>
<tr bgcolor="<?php echo ($ac_sw2++%2==0)?"#E5E5E5":"#FFFFFF"; ?>" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#999999'">
<td><?php echo $row_listaprod['descricao']; ?>
<input name="nome" type="hidden" id="nome" value="<?php echo $row_listaprod['descricao']; ?>" /></td>
<td>R$ <?php echo number_format($row_listaprod['preco1'],2,',',','); ?>
<input name="preco" type="hidden" id="preco" value="<?php echo $row_listaprod['preco1']; ?>" /></td>
<td><?php echo $row_listaprod['embalagem']; ?>
<input name="embalagem" type="hidden" id="embalagem" value="<?php echo $row_listaprod['embalagem']; ?>" /></td>
<td><label>
<input name="quantidade" type="text" value="<?php echo $row_listaprod['quantidade']; ?>" size="5" maxlength="5" />
</label></td>
<td><label>
<input type="submit" name="button" id="button" value="Pedir" />
<input name="sessao" type="hidden" id="sessao" value="<?php echo $row_sessao['sessao']; ?>" />
</label></td>
</tr>
<?php } while ($row_listaprod = mysql_fetch_assoc($listaprod)); ?>
</table>
<input type="hidden" name="MM_insert" value="form" />
</form>
<?php
echo $tNGs->getErrorMsg();
?>
<br />
<strong>Seu Pedido até agora:
</strong><br />


<table width="765" border="0">
<tr>
<td>Nome</td>
<td>Pre&ccedil;o</td>
<td>Embalagem</td>
<td>Quantidade</td>
<td>Total</td>
<td>Retirar Pedido</td>
</tr>
<?php do { ?>
<tr bgcolor="<?php echo ($ac_sw1++%2==0)?"#E5E5E5":"#FFFFFF"; ?>" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#999999'">
<td><?php echo $row_listaresultado['nome']; ?></td>
<td><?php echo $row_listaresultado['preco']; ?></td>
<td><?php echo $row_listaresultado['embalagem']; ?></td>
<td><?php echo $row_listaresultado['quantidade']; ?></td>
<td><?php echo number_format($row_listaresultado['total'],2,',',','); ?></td>
<td><a href="index.php?pagina=cliente&del=<?php echo $row_listaresultado['pedido_id']; ?>&delete=1"><img src="imagens/remover.png" width="33" height="33" border="0" /></a></td>
</tr>
<?php } while ($row_listaresultado = mysql_fetch_assoc($listaresultado)); ?>
</table>
<h3>Valor total do pedido: R$ <strong><?php echo number_format($row_soma['somatotal'],2,',',','); ?></strong></h3>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
//-->
</script>
</body>
</html>
<?php
mysql_free_result($listaprod);

mysql_free_result($soma);

mysql_free_result($listaresultado);

mysql_free_result($sessao);

?>
[/codebox]




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq