I'm trying to make a cronjob, that deletes everything from a table then refills it with random values from another table, my problem is it is only inserting 1 row, when I want it to insert 24 different ones that it grabs from the other table. any help will be very much appreciated. btw I know mysql is deprecated.
$result = mysql_query("SELECT * FROM market ORDER BY RAND() LIMIT 24"); while($row = mysql_fetch_array( $result )) { mysql_query("TRUNCATE TABLE market2"); mysql_query("INSERT INTO `market2` (`id`, `pokemon`, `price`, `type`) VALUES ('".$row['id']."', '".$row['pokemon']."', '".$row['type']."', '".$row['price']."') "); } Is the fixed version for anyone else that has this question.
$result = mysql_query("SELECT * FROM market ORDER BY RAND() LIMIT 24"); mysql_query("TRUNCATE TABLE market2"); while($row = mysql_fetch_array( $result )) { mysql_query("INSERT INTO `market2` (`id`, `pokemon`, `price`, `type`) VALUES ('".$row['id']."', '".$row['pokemon']."', '".$row['type']."', '".$row['price']."') "); }