A while loop .. not sure how to
Posted: Thu Jun 25, 2009 7:31 am
I am trying to do a loop and what i need done is i am selecting all from the user table then I need it to take the id of each users put it into the mem_id field in the support table and go until it does all the users
Here is the code i have so far
$r = mysql_query("SELECT * FROM user") or die(mysql_error());
while($info = mysql_fetch_array($r, MYSQL_ASSOC)
$q=mysql_query("INSERT into support(id,mem_id,email,subject,message,sent,status)VALUES(null,'" . $info['id'] . "','$email','$subject','$msg','$date','4')")or die(mysql_error());
@mysql_free_result($r);
}
as you can see i have it all done ecept where i make it go into the support table even though i have the query it not working I am lost on loops. anyone who can help would be nice
Thanks
Here is the code i have so far
$r = mysql_query("SELECT * FROM user") or die(mysql_error());
while($info = mysql_fetch_array($r, MYSQL_ASSOC)
$q=mysql_query("INSERT into support(id,mem_id,email,subject,message,sent,status)VALUES(null,'" . $info['id'] . "','$email','$subject','$msg','$date','4')")or die(mysql_error());
@mysql_free_result($r);
}
as you can see i have it all done ecept where i make it go into the support table even though i have the query it not working I am lost on loops. anyone who can help would be nice
Thanks