Forum Moderators: coopster

Message Too Old, No Replies

array to replace mysql/php query loop

array to replace mysql/php query loop

         

sasori

5:04 pm on Jul 10, 2009 (gmt 0)

10+ Year Member



novice here,
I have this query:
$db->query("SELECT * FROM new_ WHERE newsletters='Yes'");
while($db->movenext()){
*** stuff to do ***
}

I want to insert an update to each row of the query (based on uid); which I cannot do inside of the select/while loop. hence the need to use an array to update the database with two fields, based on uid, after the while loop finishes.

I'm not strong on arrays.

any help would be greatly appreciated

sasori

5:40 pm on Jul 10, 2009 (gmt 0)

10+ Year Member



OK, I worked out the fix:

while($db->movenext()){
$uid = trim($db->col["uid"]);
$sendUid[] = $uid;
*** stuff to do ***
}

foreach( $sendUid as $v ) {
$db->query("UPDATE new_contact SET newsletters='No', sent='Yes' WHERE uid='".$v."'");
}