Im trying to convert data from one table to another, from the ITEMS_VEHICLES table to the VEHICLES table. My code is this:
$sql_result = mysql_query("SELECT * FROM items_vehicles", $db);
while ($rs = mysql_fetch_array($sql_result)) {
if ($rs[motorbike] > 0) { mysql_query("INSERT INTO vehicles (type, player, hp) VALUES('1', '$rs[player]', '50')"); }
if ($rs[banger] > 0) { mysql_query("INSERT INTO vehicles (type, player, hp) VALUES('2', '$rs[player]', '50')");
}
etc
But the $rs[motorbike] and other fields i want them to insert that code the amount of times in that column. Example, if $rs[motorbike] was '5', I want that insert query ran 5 times.
I'm in a bind, not sure how to do it.
'$rs[player]'should be'{$rs[player]}'or'".$rs[player]."'. You should also avoid using inherent strings (such as$rs[player], seeplayer) and instead use quoted strings like'{$rs["player"]}'.display_errors, as your code produces all sorts of notices you must not be seeing.$rs['motorbike']Notice: Use of undefined constant motorbike