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
Share on other sites

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 by moisesbr
Link to comment
Share on other sites

 

 

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 by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.