I have SELECT
to return the value of a field of table funcionarionew
, my idea is to save the result of SELECT
on 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'");