Hello all,
I'm working with two MySQL tables - "votes" and "messages".
I have a variable...
$mid
...which contains the string...
23,304,405,500,550,569,600
Each number is an ID which corresponds to records in the message table.(message_id)
As you can see, $mid is used in both the following SELECT and UPDATE statements. I need to somehow loop the following SELECT and UPDATE statements for each number contained in $mid. So execute the INSERT and UPDATE using $mid 23, then execute the INSERT UPDATE using $mid 304, etc etc until all numbers have been run through.
What type of loop should I use to execute the following queries for each number(ID) in $mid?
$query_rs_vote_count = "SELECT vote_mid FROM votes WHERE vote_mid = '$mid'";
$rs_vote_count = mysql_query($query_rs_vote_count, $Messages) or die(mysql_error());
$row_rs_vote_count = mysql_fetch_assoc($rs_vote_count);
$totalRows_rs_vote_count = mysql_num_rows($rs_vote_count);
$updateSQL = "UPDATE messages SET message_votes='$totalRows_rs_vote_count' WHERE message_id='$mid'";
I've tried several loops but can't figure it out. Maybe because $mid needs to be made into an array first? Not sure how to break the numbers down and place them into an array either though! HAHA
Thank you very much.
Peter