0
I have a SELECT
to return the value of a table field funcionarionew
, my idea is to save the result of SELECT
into a variable and then insert the value of that variable into another table (terminal_cartao
).
In my code, the variable $cod
always has value 0
, which is not correct. What will be the problem?
include('connectdb.php');
$cli = $_POST['cliente'];
$car = $_POST['descricao'];
$loc = $_POST['local'];
$vend = $_POST['codigoVend'];
$sqlcode = mysql_query("UPDATE terminal_cartao SET cliente='$cli', local='$loc' WHERE descricao='$car'");
$sql="SELECT codigo FROM funcionarionew WHERE nome='$vend'";
while($ex=mysql_fetch_array($sql)){
$cod=$ex['codigo'];
}
$sqlcode1 = mysql_query("UPDATE terminal_cartao SET vendedor='$cod' WHERE descricao='$car'");
a doubt your $Vend is a code or name ? vi that is catching $_POST['codeVend'] ?
– Luciano Azevedo
@Lucianoazevedo is a name, string
– Rene Sá
Have you tried running this sql directly in the database ? returned ? checked if $_POST is not coming null ? pq whille ?
– Luciano Azevedo
But you are not doing the $SQL query
– Daniel Gregatto
Running straight into the bank is "ok", the $_POST also checked, is correct.
– Rene Sá
as @Daniel Gregatto said, missing $sql = mysql_query("SELECT code....")
– Luciano Azevedo
All the error for a silly distraction! the problem was that I didn’t put mysql_query in $sql. : ( Thank you guys
– Rene Sá