Jump to content

Scanning a table


moisesbr

Recommended Posts

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

  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

  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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.