#native_company# #native_desc#
#native_cta#

Simple table update in while loop

By Jorge
on November 3, 2001

Version: 1

Type: Sample Code (HOWTO)

Category: Databases

License: GNU General Public License

Description: an easy way to update a row in a while loop.

<?
$email_query="select * from email";
$email_result=mysql_query($email_query);

if ($send == 2) {
print("<p>Email being cleared");
while ($email=mysql_fetch_row($email_result)) {

if ($email[1] == 'y') { 
 $email_mysql_query = ("UPDATE email SET sent='n' WHERE id = $email[3]"); 
 $email_mysql_query_result = mysql_query($email_mysql_query); 
 print ("<p>email cleaned"); 
}

}
}
?>