0

Pulled out remaining hair trying to get this to work. Echo of incremented "qty" and "item" displays fine. However, no data is being updated to the table in this query. I have tried every combination of quotes, encased double quotes, etc. to know avail. Code below. The column names need to be incremented by one in each pass (qty2, qty3, qty4, etc. along with the variable data in each corresponding item2, item3, item4, etc.

$jobnumberselected = mysql_insert_id();
$x = 2; 
do 
{
$qty=${'qty'.$x};
$item=${'item'.$x};

echo $qty.$item;

mysql_query("UPDATE shoppinglist 
SET $qty='$qty',item$='$item' 
WHERE jobnumber=$jobnumberselected");

$x++;
} 
while ($item !=='');
Filburt
  • 17,626
  • 12
  • 64
  • 115
  • Why are you using database functions that have been deprecated for 5 years, and not even present in the current version of PHP? http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – miken32 Jan 18 '16 at 23:14
  • Why are you trying to invite SQL injection by building queries out of strings instead of using a prepared statement? http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php/ – miken32 Jan 18 '16 at 23:16

0 Answers0