I need to, select data from a table and then make changes and update is the same tabele and another table.
Right now my code is very simple and is giving some erros, right now, he just search the table. can you hepl me?
<?php
//conecção ao servidor
mysql_connect("localhost", "root")or die("sem conecção ao servidor");
mysql_select_db("sermail")or die("Base de dados não foi encontrada");
$nordem = $_POST['nordem'];
$query="SELECT * FROM entrada where nordem_n = '" . mysql_real_escape_string($nordem) . "'";
mysql_query ($query) or die(mysql_error());
$result=mysql_query($query);
$query1="SELECT * FROM ordem where nordem = '" . mysql_real_escape_string($nordem) . "'";
mysql_query ($query1) or die(mysql_error());
$result1=mysql_query($query1);
$num = mysql_num_rows($result);
mysql_close();
?>
<?php
$o1= mysql_result($result1,"data");
$o2= mysql_result($result1,"nordem");
$o3= mysql_result($result1,"fornecedor");
$o4= mysql_result($result1,"guian");
$o5= mysql_result($result1,"ncliente");
$o6= mysql_result($result1,"cliente");
?>
<FORM>
<INPUT TYPE="button" value="Imprimir" onClick="window.print()">
</FORM>
<table><tr>
<td><h1>Data:</h1></td><h1><?php echo $o1; ?></h1></td>
<td><h1>N.º Ordem:</h1> </td> <td><?php echo $o2; ?></td>
<td><h1>Fornecedor:</h1> </td> <td><?php echo $o3; ?></td>
<td> <h1>Guia n.º:</h1> </td> <td><?php echo $o4; ?></td>
</TR>
<tr>
<td><h1>N.º Cliente:</h1></td><td><?php echo $o5; ?></td>
<td><h1>Cliente:</h1> </td> <td><?php echo $o6; ?></td>
</tr></table>
<table>
<tr><td width="80%"></TD><td><img src="imas/sermailpb.png"></td></tr></table>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Arial, sans-serif">N.º Ordem</font></td>
<td><font face="Arial, sans-serif">Codigo </br>Produto</font></td>
<td><font face="Arial, sans-serif">Codigo Cliente </br>1-Lote</font></td>
<td><font face="Arial, sans-serif">Codigo Cliente </br>2-Validade</font></td>
<td><font face="Arial, sans-serif">Designacao</font></td>
<td><font face="Arial, sans-serif">Filtro</font></td>
<td><font face="Arial, sans-serif">Familia Marca</font></td>
<td><font face="Arial, sans-serif">Quant Guia</font></td>
<td><font face="Arial, sans-serif">Quant Conferida</font></td>
<td><font face="Arial, sans-serif">Atado</font></td>
<td><font face="Arial, sans-serif">Posicao</font></td>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"nordem_n");
$f2=mysql_result($result,$i,"codprod");
$f3=mysql_result($result,$i,"lote");
$f4=mysql_result($result,$i,"val");
$f5=mysql_result($result,$i,"designacao");
$f6=mysql_result($result,$i,"filtro");
$f7=mysql_result($result,$i,"familiamarca");
$f8=mysql_result($result,$i,"quantguia");
$f9=mysql_result($result,$i,"quantconf");
$f10=mysql_result($result,$i,"atado");
$f11=mysql_result($result,$i,"posicao");
?>
<style type="text/css" media="print">
.button {
visibility: hidden;
display: none;
size: Landscape;
}
</style>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f7; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f8; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f9; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f10; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f11; ?></font></td>
</tr>
<?php
$i++;
}
?>
the output:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'nordem_n = '1'' at line 1