I'm trying to write a Top-10 list with categories but it doesn't work in the way i want it to. There's an array with a dynamic number (n) of items and want to loop each item in this array 10 times to write n*10 rows into a MySQL table. ($i also increments the games rank). If I echo, print_r or var_dump the code it works, but when I try to write it to the MySQL table it doesn't work.
Here's the code:
for ($i = 1; $i <= 10; $i++) {
foreach($titles as $val) {
$query .= "INSERT INTO charts (game_place, game_name, game_preweek, game_developer, game_release, game_link, game_image, game_category, charts_updated) VALUES (".$i.", '', '', '', '', '', '', '".$val."', '".time()."');";
mysql_query($query);
};
};
Does somebody know the answer to my problem?
Regards, Manuel
INSERT INTO charts (game_place, game_category, charts_updated) VALUES (".$i.", '".$val."', '".time()."');
– Banning Jul 16 at 15:20