moisesbr Posted February 15, 2014 Share Posted February 15, 2014 Hi I have a email table (to, email, subject , ect.) and already have the php code to send may from a record of the table. Now I need a way to scan the table and execute my code to build email from each row of the table. Something as : Scan table email where sent = 0 Is there any hint about this issue ? Moises Quote Link to comment https://forums.phpfreaks.com/topic/286213-scanning-a-table/ Share on other sites More sharing options...
trq Posted February 15, 2014 Share Posted February 15, 2014 Your talking about a pretty simple SQL query. SELECT email FROM tbl WHERE sent = 0; Quote Link to comment https://forums.phpfreaks.com/topic/286213-scanning-a-table/#findComment-1469030 Share on other sites More sharing options...
moisesbr Posted February 15, 2014 Author Share Posted February 15, 2014 (edited) Your talking about a pretty simple SQL query. SELECT email FROM tbl WHERE sent = 0; I don't think so. I have to go through the table looking for sent = 0 condition and executing a code at every row where sent = 0 and replacing sent with 1. Edited February 15, 2014 by moisesbr Quote Link to comment https://forums.phpfreaks.com/topic/286213-scanning-a-table/#findComment-1469048 Share on other sites More sharing options...
trq Posted February 15, 2014 Share Posted February 15, 2014 So do so. What is the actual problem? Quote Link to comment https://forums.phpfreaks.com/topic/286213-scanning-a-table/#findComment-1469049 Share on other sites More sharing options...
Ch0cu3r Posted February 15, 2014 Share Posted February 15, 2014 (edited) I have to go through the table looking for sent = 0 use the query trq suggested and executing a code at every row where sent = 0 You'd loop through all the results of a query using a while loop, example $result = $mysqli->query( the select query ); // query db // loop through results while($row = $result->fetch_assoc()) { // now do something with $row['email'] in here } and replacing sent with 1. You'd run an update query, // now run an update query on your table, setting sent to 1 $mysqli->query( the update query ); You'd use the exact same WHERE clause used in the SELECT query for the UPDATE query. Edited February 15, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/286213-scanning-a-table/#findComment-1469053 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.