unplugged_web Posted December 15, 2010 Share Posted December 15, 2010 I'm trying to get the results from one table, set a field to true, add the results to another table and repeat it 100 times. I've read about for loop and think that this is what I need to use and have written some code, but just wanted a bit of advice about it please.This is what I've got: <?php$con = mysql_connect("hostname/server IP","username","password");if (!$con) { die('Could not connect: ' . mysql_error()); }for($i=100) { echo $i mysql_select_db("databasename", $con);mysql_query("SELECT * FROM table_one WHERE picked = 'false' LIMIT '1'");mysql_query("UPDATE table_one SET picked = 'true'");mysql_query("INSERT INTO table_two");}mysql_close($con);?> but I didn't know if it was right and if it would work.Thanks in advance for any advice on this. Link to comment Share on other sites More sharing options...
birbal Posted December 15, 2010 Share Posted December 15, 2010 you can do like UPDATE table_one SET picked = 'true' WHERE picked='false' if i am not missunderstanding the problem..it should work i think.. add the results to another table and repeat it 100 timesi am not sure about this..what results are you reffering? all the result from table1 or ony updated row's result? Link to comment Share on other sites More sharing options...
unplugged_web Posted December 15, 2010 Author Share Posted December 15, 2010 you can do likeUPDATE table_one SET picked = 'true' WHERE picked='false' if i am not missunderstanding the problem..it should work i think..i am not sure about this..what results are you reffering? all the result from table1 or ony updated row's result? ThanksIt's only the updated results that I want to add to the other table Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.