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 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; 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 On 2/15/2014 at 1:06 PM, trq said: 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. 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? 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 Quote I have to go through the table looking for sent = 0 use the query trq suggested Quote 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 } Quote 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. Link to comment https://forums.phpfreaks.com/topic/286213-scanning-a-table/#findComment-1469053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.