Estou fazendo um sistema em php de cadastro de encomendas. Estou seguindo aquela apostila "Dreamweaver 8 - a bíblia". Segui todos os passos para fazer a página de alteração de dados. Tudo funciona, exceto que os dados não aparecem no formulário de alteração. Abaixo seguem os códigos php das páginas:
$query_Recordset_resultado_busca_encomenda = sprintf("SELECT * FROM encomendas WHERE cliente LIKE '%%%s%%'", $colname_Recordset_resultado_busca_encomenda);
$Recordset_resultado_busca_encomenda = mysql_query($query_Recordset_resultado_busca_encomenda, $ConnImasters) or die(mysql_error());
Pergunta
fredebsb
Boa noite pessoal.
Estou fazendo um sistema em php de cadastro de encomendas. Estou seguindo aquela apostila "Dreamweaver 8 - a bíblia". Segui todos os passos para fazer a página de alteração de dados. Tudo funciona, exceto que os dados não aparecem no formulário de alteração. Abaixo seguem os códigos php das páginas:
Página de busca:
<?php require_once('Connections/ConnImasters.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 ((isset($_POST['codigo'])) && ($_POST['codigo'] != "") && (isset($_GET['codigo']))) {
$deleteSQL = sprintf("DELETE FROM encomendas WHERE codigo=%s",
GetSQLValueString($_POST['codigo'], "int"));
mysql_select_db($database_ConnImasters, $ConnImasters);
$Result1 = mysql_query($deleteSQL, $ConnImasters) or die(mysql_error());
$deleteGoTo = "index.html";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_Recordset_busca_encomenda = "-1";
if (isset($_GET['cliente'])) {
$colname_Recordset_busca_encomenda = (get_magic_quotes_gpc()) ? $_GET['cliente'] : addslashes($_GET['cliente']);
}
mysql_select_db($database_ConnImasters, $ConnImasters);
$query_Recordset_busca_encomenda = sprintf("SELECT * FROM encomendas WHERE cliente LIKE '%%%s%%'", $colname_Recordset_busca_encomenda);
$Recordset_busca_encomenda = mysql_query($query_Recordset_busca_encomenda, $ConnImasters) or die(mysql_error());
$row_Recordset_busca_encomenda = mysql_fetch_assoc($Recordset_busca_encomenda);
$totalRows_Recordset_busca_encomenda = mysql_num_rows($Recordset_busca_encomenda);
?>
<!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>
<title>Area do administrador</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
body {
margin-right: 0px;
}
.style4 {
font-size: 11px;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.style5 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}
#Layer1 {
position:absolute;
left:87px;
top:15px;
width:777px;
height:60px;
z-index:1;
}
#Layer2 {
position:absolute;
left:10px;
top:72px;
width:2px;
height:2px;
z-index:2;
}
#Layer3 {
position:absolute;
width:853px;
height:61px;
z-index:1;
left: 11px;
top: 16px;
}
#Layer4 {
position:absolute;
width:200px;
height:297px;
z-index:2;
top: 77px;
}
#Layer5 {
position:absolute;
width:1px;
height:1px;
z-index:3;
}
#Layer6 {
position:absolute;
width:437px;
height:115px;
z-index:4;
top: 374px;
left: 213px;
}
#Layer7 {
position:absolute;
left:215px;
top:376px;
width:531px;
height:107px;
z-index:4;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body>
<table width="914" border="0" align="left">
<tr>
<td width="1104" height="441" valign="top">
<table width="150" border="0" align="right">
</table>
<div align="left">
<table width="699" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#FF0000"><div align="center">Área do administrador</div></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#CCCCCC"><table width="546" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="109"><div align="left"></div></td>
<td width="109"><div align="left"></div></td>
<td width="102"><div align="left"></div></td>
<td width="215"><div align="left"><span class="style4">Encomendas</span></div></td>
<td width="11"><div align="left"></div></td>
</tr>
</table></td>
<td align="left" valign="top" bgcolor="#CCCCCC"> </td>
<td><div align="right"><a href="">Logout</a></div></td>
</tr>
<tr>
<td width="579" align="left" valign="top"><div align="center">
<table width="545" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="136"><table width="118" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table></td>
<td width="136"> </td>
<td width="97"> </td>
<td width="176"> </td>
</tr>
</table>
</div></td>
<td width="95" align="left" valign="top"> </td>
<td width="43"> <div align="center"></div></td>
</tr>
</table>
<table width="904" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="1" rowspan="2" valign="top"><div id="Layer5"></div></td>
<td width="903" valign="top"><table width="761" height="201" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="436" height="201" valign="top"><table width="755" height="171" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="755" valign="top"><iframe src="tabela_encomendas.php" name="iframe_tb_encomendas" width="750" height="300" align="left" scrolling="auto"></iframe></td>
</tr>
</table></td>
<td width="325" valign="top"><table width="136" height="297" border="0" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
<tr bordercolor="#FF0000">
<td width="233" height="55" valign="top"><table width="133" height="75" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="233" height="29" colspan="2"><div align="left">Deletar Encomenda </div></td>
</tr>
<tr>
<td height="46" colspan="2" valign="top"><form id="form_deleta_encomenda" name="form_deleta_encomenda" method="get" action="encomenda_deletada.php">
<table width="130" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td><input name="codigo" type="hidden" id="codigo" value="<?php echo $_GET['codigo]; ?>" /></td>
</tr>
<tr>
<td width="46"><div align="center">Id</div></td>
<td width="84"><label>
<input name="codigo" type="text" id="codigo" value="" size="3" />
<input name="deletar" type="submit" id="deletar" value="Deletar" />
</label></td>
</tr>
</table>
</form> </td>
</tr>
</table>
<table width="133" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center">
<input name="Submit4" type="submit" onclick="MM_goToURL('parent','encomendas.php');MM_goToURL('parent','busca_encomenda.php');MM_goToURL('parent','busca_encomenda.php');return document.MM_returnValue" value="Encomendas" />
</div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center">
<input name="Submit2" type="submit" onclick="MM_goToURL('parent','area_do_administrador.php');return document.MM_returnValue" value="Administrador" />
</div></td>
</tr>
</table>
<p> </p></td>
</tr>
<tr>
<td height="19" valign="top" bgcolor="#FFFFFF"><p align="center"> </p> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="19" valign="top"><table width="903" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" bgcolor="#00FF33"><div align="center">Buscar Encomendas </div></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">
<form id="form_busca_encomenda" name="form_busca_encomenda" method="get" action="resultado_busca_encomenda2.php">
<table width="257" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="8"> </td>
<td width="38"><div align="center"> Nome</div></td>
<td width="144"><label>
<input name="cliente" type="text" id="cliente" />
</label></td>
<td width="67"><label>
<input name="buscar" type="submit" id="buscar" value="Buscar" />
</label></td>
</tr>
</table>
</form> </td>
</tr>
<tr>
<td colspan="3"><table width="525" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"><form id="form1" name="form1" method="post" action="">
<table width="524" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="104"><label></label></td>
<td width="10"><label></label></td>
<td width="410"><label></label></td>
</tr>
</table>
</form> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="451"></td>
<td width="451"> </td>
<td width="1"> </tr>
</table></td>
</tr>
</table>
</div> <p align="center"> </p></td>
</tr>
</table>
<table>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset_busca_encomenda);
?>
// fim da página de busca
Página de resultado da busca:
<?php require_once('Connections/ConnImasters.php'); ?>
<?php
$colname_Recordset_resultado_busca_encomenda = "-1";
if (isset($_GET['cliente'])) {
$colname_Recordset_resultado_busca_encomenda = (get_magic_quotes_gpc()) ? $_GET['cliente'] : addslashes($_GET['cliente']);
}
mysql_select_db($database_ConnImasters, $ConnImasters);
$query_Recordset_resultado_busca_encomenda = sprintf("SELECT * FROM encomendas WHERE cliente LIKE '%%%s%%'", $colname_Recordset_resultado_busca_encomenda);
$Recordset_resultado_busca_encomenda = mysql_query($query_Recordset_resultado_busca_encomenda, $ConnImasters) or die(mysql_error());
$row_Recordset_resultado_busca_encomenda = mysql_fetch_assoc($Recordset_resultado_busca_encomenda);
$totalRows_Recordset_resultado_busca_encomenda = mysql_num_rows($Recordset_resultado_busca_encomenda);
?>
<?php require_once('Connections/ConnImasters.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 ((isset($_POST['codigo'])) && ($_POST['codigo'] != "") && (isset($_GET['codigo']))) {
$deleteSQL = sprintf("DELETE FROM encomendas WHERE codigo=%s",
GetSQLValueString($_POST['codigo'], "int"));
mysql_select_db($database_ConnImasters, $ConnImasters);
$Result1 = mysql_query($deleteSQL, $ConnImasters) or die(mysql_error());
$deleteGoTo = "index.html";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_Recordset_busca_encomenda = "-1";
if (isset($_GET['cliente'])) {
$colname_Recordset_busca_encomenda = (get_magic_quotes_gpc()) ? $_GET['cliente'] : addslashes($_GET['cliente']);
}
mysql_select_db($database_ConnImasters, $ConnImasters);
$query_Recordset_busca_encomenda = sprintf("SELECT * FROM encomendas WHERE cliente LIKE '%%%s%%'", $colname_Recordset_busca_encomenda);
$Recordset_busca_encomenda = mysql_query($query_Recordset_busca_encomenda, $ConnImasters) or die(mysql_error());
$row_Recordset_busca_encomenda = mysql_fetch_assoc($Recordset_busca_encomenda);
$totalRows_Recordset_busca_encomenda = mysql_num_rows($Recordset_busca_encomenda);
?>
<!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>
<title>Area do administrador</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
body {
margin-right: 0px;
}
.style4 {
font-size: 11px;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
#Layer1 {
position:absolute;
left:87px;
top:15px;
width:777px;
height:60px;
z-index:1;
}
#Layer2 {
position:absolute;
left:10px;
top:72px;
width:2px;
height:2px;
z-index:2;
}
#Layer3 {
position:absolute;
width:853px;
height:61px;
z-index:1;
left: 11px;
top: 16px;
}
#Layer4 {
position:absolute;
width:200px;
height:297px;
z-index:2;
top: 77px;
}
#Layer5 {
position:absolute;
width:1px;
height:1px;
z-index:3;
}
#Layer6 {
position:absolute;
width:437px;
height:115px;
z-index:4;
top: 374px;
left: 213px;
}
#Layer7 {
position:absolute;
left:215px;
top:376px;
width:531px;
height:107px;
z-index:4;
}
.style8 {color: #00FF33}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body>
<table width="4411" border="0" align="left">
<tr>
<td width="4411" height="441" valign="top">
<table width="150" border="0" align="right">
</table>
<div align="left">
<table width="776" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#FF0000"><div align="center">Área do administrador</div></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#CCCCCC"><table width="546" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="109"><div align="left"></div></td>
<td width="109"><div align="left"></div></td>
<td width="102"><div align="left"></div></td>
<td width="215"><div align="left"><span class="style4">Encomendas</span></div></td>
<td width="11"><div align="left"></div></td>
</tr>
</table></td>
<td align="left" valign="top" bgcolor="#CCCCCC"> </td>
<td><div align="right"><a href="">Logout</a></div></td>
</tr>
<tr>
<td width="594" align="left" valign="top"><div align="center">
<table width="545" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="136"><table width="118" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table></td>
<td width="136"> </td>
<td width="97"> </td>
<td width="176"> </td>
</tr>
</table>
</div></td>
<td width="131" align="left" valign="top"> </td>
<td width="101"> <div align="center"></div></td>
</tr>
</table>
<table width="752" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="1" rowspan="2" valign="top"><div id="Layer5"></div></td>
<td width="741" valign="top"><table width="761" height="201" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="436" height="201" valign="top"><table width="755" height="171" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="750" valign="top"><iframe src="tabela_encomendas.php" name="iframe_tb_encomendas" width="750" height="300" align="left" scrolling="auto"></iframe></td>
</tr>
</table></td>
<td width="325" valign="top"><table width="166" height="297" border="0" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
<tr bordercolor="#FF0000">
<td width="153" height="55" valign="top"><table width="133" height="75" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="233" height="29" colspan="2"><div align="left">Deletar Encomenda </div></td>
</tr>
<tr>
<td height="46" colspan="2" valign="top"><form id="form_deleta_encomenda" name="form_deleta_encomenda" method="get" action="encomenda_deletada.php">
<table width="130" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td><input name="codigo" type="hidden" id="codigo" value="<?php echo $_GET['codigo]; ?>" /></td>
</tr>
<tr>
<td width="46"><div align="center">Id</div></td>
<td width="84"><label>
<input name="codigo" type="text" id="codigo" value="" size="3" />
<input name="deletar" type="submit" id="deletar" value="Deletar" />
</label></td>
</tr>
</table>
</form> </td>
</tr>
</table>
<table width="132" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td><input name="Submit4" type="submit" onclick="MM_goToURL('parent','encomendas.php');MM_goToURL('parent','busca_encomenda.php');MM_goToURL('parent','busca_encomenda.php');return document.MM_returnValue" value="Encomendas" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><input name="Submit2" type="submit" onclick="MM_goToURL('parent','area_do_administrador.php');return document.MM_returnValue" value="Administrador" /></td>
</tr>
</table> <p> </p></td>
</tr>
<tr>
<td height="19" valign="top" bgcolor="#FFFFFF"><p align="center"> </p> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="19" valign="top"><table width="1051" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td colspan="3" bgcolor="#00FF33"><div align="left">Resultado da Busca: <span class="style8">....</span> <?php echo $row_Recordset_resultado_busca_encomenda['cliente']; ?></div></td>
</tr>
<tr>
<td colspan=3"><table width="571" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">
<form id="form_busca_encomenda" name="form_busca_encomenda" method="get" action="resultado_busca_encomenda2.php">
<table width="245" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40"> </td>
<td width="144"> </td>
<td width="131"> </td>
</tr>
</table>
</form> </td>
</tr>
<tr>
<td colspan="3"><table width="525" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">
<table width="647" border="1" cellspacing="0" cellpadding="0">
<tr bgcolor="#00FFCC">
<td width="36"><div align="center">Cód Enc. </div></td>
<td width="65"><div align="center">Cliente</div></td>
<td width="77"><div align="center">Produtos</div></td>
<td width="24"><div align="center">Qtd</div></td>
<td width="65"><div align="center">Data pedido </div></td>
<td width="67"><div align="center">Data entrega </div></td>
<td width="62"><div align="center">Tel Fixo </div></td>
<td width="65"><div align="center">E-mail</div></td>
<td width="65"><div align="center">Tel Cel </div></td>
<td width="21"><div align="center">Uf</div></td>
<td width="76"><div align="center">Cidade</div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<?php do { ?>
<td><div align="center"><a href="altera_encomenda.php?pegaCod=<?php echo $row_Recordset_resultado_busca_encomenda['codigo]; ?>"><?php echo $row_Recordset_resultado_busca_encomenda['codigo']; ?></a></div></td>
<td><div align=center"><?php echo $row_Recordset_resultado_busca_encomenda['cliente]; ?></div></td>
<td><div align="center"><?php echo $row_Recordset_resultado_busca_encomenda['produtos']; ?></div></td>
<td><div align=center"><?php echo $row_Recordset_resultado_busca_encomenda['quantidade]; ?></div></td>
<td><div align="center"><?php echo $row_Recordset_resultado_busca_encomenda['datadopedido']; ?></div></td>
<td><div align=center"><?php echo $row_Recordset_resultado_busca_encomenda['prazoentrega]; ?></div></td>
<td><div align="center"><?php echo $row_Recordset_resultado_busca_encomenda['telfixo']; ?></div></td>
<td><div align=center"><?php echo $row_Recordset_resultado_busca_encomenda['email]; ?></div></td>
<td><div align="center"><?php echo $row_Recordset_resultado_busca_encomenda['telcelular']; ?></div></td>
<td><div align=center"><?php echo $row_Recordset_resultado_busca_encomenda['estado]; ?></div></td>
<td><div align="center"><?php echo $row_Recordset_resultado_busca_encomenda['cidade']; ?></div></td>
<?php } while ($row_Recordset_resultado_busca_encomenda = mysql_fetch_assoc($Recordset_resultado_busca_encomenda)); ?></tr>
</table> </td>
</tr>
<tr>
<td colspan=3"> </td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"><form id="form1" name="form1" method="post" action="">
<table width="524" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="104"><label></label></td>
<td width="10"><label></label></td>
<td width="410"><label></label></td>
</tr>
</table>
</form> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="525"></td>
<td width="525"> </td>
<td width="1"> </tr>
</table></td>
</tr>
</table>
</div> <p align="center"> </p></td>
</tr>
</table>
<table>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset_busca_encomenda);
?>
// Fim da página de busca de encomenda
Página de alteracao de encomenda:
<html>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Codigo:</td>
<td><?php echo $row_Recordset1['codigo]; ?></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Cliente:</td>
<td><input type="text" name="cliente" value="<?php echo $row_Recordset1['cliente']; ?>" size=32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Telfixo:</td>
<td><input type="text" name="telfixo" value="<?php echo $row_Recordset1['telfixo]; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Telcelular:</td>
<td><input type="text" name="telcelular" value="<?php echo $row_Recordset1['telcelular']; ?>" size=32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Endereco:</td>
<td><input type="text" name="endereco" value="<?php echo $row_Recordset1['endereco]; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Bairro:</td>
<td><input type="text" name="bairro" value="<?php echo $row_Recordset1['bairro']; ?>" size=32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Cidade:</td>
<td><input type="text" name="cidade" value="<?php echo $row_Recordset1['cidade]; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Estado:</td>
<td><input type="text" name="estado" value="<?php echo $row_Recordset1['estado']; ?>" size=32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Cep:</td>
<td><input type="text" name="cep" value="<?php echo $row_Recordset1['cep]; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="<?php echo $row_Recordset1['email']; ?>" size=32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Produtos:</td>
<td><input type="text" name="produtos" value="<?php echo $row_Recordset1['produtos]; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Datadopedido:</td>
<td><input type="text" name="datadopedido" value="<?php echo $row_Recordset1['datadopedido']; ?>" size=32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Prazoentrega:</td>
<td><input type="text" name="prazoentrega" value="<?php echo $row_Recordset1['prazoentrega]; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Quantidade:</td>
<td><input type="text" name="quantidade" value="<?php echo $row_Recordset1['quantidade']; ?>" size=32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="codigo" value="<?php echo $row_Recordset1['codigo]; ?>">
</form>
<p> </p>
<?php require_once('Connections/ConnImasters.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 encomendas SET cliente=%s, telfixo=%s, telcelular=%s, endereco=%s, bairro=%s, cidade=%s, estado=%s, cep=%s, email=%s, produtos=%s, datadopedido=%s, prazoentrega=%s, quantidade=%s WHERE codigo=%s",
GetSQLValueString($_POST['cliente'], "text"),
GetSQLValueString($_POST['telfixo'], "int"),
GetSQLValueString($_POST['telcelular'], "text"),
GetSQLValueString($_POST['endereco'], "text"),
GetSQLValueString($_POST['bairro'], "text"),
GetSQLValueString($_POST['cidade'], "text"),
GetSQLValueString($_POST['estado'], "text"),
GetSQLValueString($_POST['cep'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['produtos'], "text"),
GetSQLValueString($_POST['datadopedido'], "date"),
GetSQLValueString($_POST['prazoentrega'], "text"),
GetSQLValueString($_POST['quantidade'], "int"),
GetSQLValueString($_POST['codigo'], "int"));
mysql_select_db($database_ConnImasters, $ConnImasters);
$Result1 = mysql_query($updateSQL, $ConnImasters) or die(mysql_error());
$updateGoTo = "encomenda_alterada.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Recordset1 = "-1";
if (isset($_GET['pegaCod'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['pegaCod'] : addslashes($_GET['pegaCod']);
}
mysql_select_db($database_ConnImasters, $ConnImasters);
$query_Recordset1 = sprintf("SELECT * FROM encomendas WHERE codigo = %s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $ConnImasters) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_free_result($Recordset1);
?>
</html>
// fim da pagina de alteracao de encomenda
Alguém sabe me dizer porque os dados não aparecem no formulário da página "alteracao de encomenda"?
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.