Jump to content


AlexCardoso

Member Since 06/10/2009
Offline Last Active 24/11/2011, 16:41
-----

Topics I've Started

List Menu

11/11/2009, 16:47

Pessoal é o seguinte, tenho um list menu que pega os dados do banco, queria saber como faço para imprimir na tela o valor escolhido nesse liste/menu
abaixo o código
[codebox]<select name="" size="1" >
<option selected="selected">Escolha</option>
<?php
$sql_cliente=mysql_query("SELECT * FROM clientes WHERE nivel_cliente='c' AND id_vendedor='1'");
while($linha=mysql_fetch_array($sql_cliente))
{
?>
<option value="$nome"><?php echo $linha['fantasia_cliente']; ?></option>
</select>
<?php } ?>
[/codebox]

Valeu...

Text Field Nao Funciona Com Repeat Region

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]

Campos Em Branco Mysql

15/10/2009, 20:15

Pessoal, preciso da ajuda de voces..
Fiz um script simples para incluir os emails no banco de dados, ele insere tudo normal, mas quando vou ver no banco, tem varios campos em branco...tipo assim..

id email
102 teste@teste.com
103 campo vazio
104 campo vazio
105 teste@teste.com


abaixo meu codigo
[codebox]<form action="index.php" method="post">

<table border="0" align="center">
<tr>
<td >Email</td>
<td ><span id="sprytextfield1">
<label>
<input type="text" name="email" />
</label>
</tr>
<tr>
<td><label>
<input type="submit" name="button" id="button" value="Enviar" />
</label></td>
<td>&nbsp;</td>
</tr>
</table>

</form>[/codebox]

codigo php

[codebox]<?php
$conn=mysql_connect("host","usuario","senha");
$sel=mysql_select_db("banco",$conn);

$email_disp=@$_POST['email'];
$qr=mysql_query("INSERT INTO email(email)VALUES('$email_disp')");

?>[/codebox]


Valeu pela ajuda pessoal...

Sistema Comentario Em Php

06/10/2009, 11:28

Pessoal, estou com um problema, fiz um sistema de comentarios em php+Mysql, ele insere o comentario normal, mas depois de inserir o comentario se eu clico em atualizar pagina ele insere o mesmo comentario, se eu atualizar a pagina 10 vezes ele insere o mesmo comentario 10 vezes, alguem tem ideia do que pode ser ?
Eu fiz um include na minha pagina principal usando o codigo abaixo.
Obrigado!


abaixo meu codigo php
[codebox]<?php
include_once("conexao.php");
?>


<?php
$nome=$_POST["nome"];
$email=$_POST["email"];
$data=date("Y-d-m");
$cidade=$_POST["cidade"];
$mensagem=$_POST["mensagem"];

$inserir=mysql_query("insert into recados(nome,email,cidade,mensagem) values('$nome','$email','$cidade','$mensagem')");
?>


<?php
//lista os resultados da pesquisa quer do MYSQL
$sql="SELECT * FROM recados ORDER BY id DESC";
$exec=mysql_query($sql);
while($exibir=mysql_fetch_array($exec)){
echo"<span class='nomes'>".$exibir["nome"]. "-" .$exibir["email"]."</span>";
echo "<br />";
echo"<span class='data'>".$data."-".$exibir["cidade"];"</span>";
echo "<br />";
echo"<span class='mensagem'>".$exibir["mensagem"]."</span>";
echo "<br />";
echo "<br />";
echo "<br />";
echo "<br />";
}
?>

<?php
mysql_close($conn);
?>[/codebox]

IPB Skin By Virteq