sundance1980
MIS
Hello I trying to have a page update all users ages at once using php/mysql. Justt for example purposes I chose this 'age senario'.
I had it working by updating one person at a time, but when I tried to display all users to the page and update everyones age at once via a post...that is when I got into trouble.
My question is..do I need a loop when I execute: $query = mysql_query ("UPDATE user set age = ' $age' WHERE id = $id");
Any help would be very helpful. thanks much.
A small example of my code:
I had it working by updating one person at a time, but when I tried to display all users to the page and update everyones age at once via a post...that is when I got into trouble.
My question is..do I need a loop when I execute: $query = mysql_query ("UPDATE user set age = ' $age' WHERE id = $id");
Any help would be very helpful. thanks much.
A small example of my code:
Code:
if($do =="modify")
{
<form action=update.php method=post>
<input type=hidden name=do value=modify_age>
$query="select * from users order by last ASC";
$result=mysql_query($query);
while($rs1=mysql_fetch_array($result))
{
echo "
"<input type=hidden name=id value=$rs1[last_name]>
Update user $rs1[last_name] Age:
<input type=text name=age size=3 value=\"
\"><br>\n";
}
echo <input type=submit value=\"Modify\"></form>";
}
if($do == "modify_age")
{
$query = mysql_query ("UPDATE users set age = ' $age' WHERE id = $id");
echo "Modified successfully"
";
}