updating mysql db with php
Posted: Sun Aug 29, 2004 8:15 pm
I have an ranking system in place, which would allow a back end admin to rank users. My only problem comes in updating the mysql database. the password works fine. I am using a hidden field to store variables, which I use the explode() function to transform into an array.
I believe this is proper sintax but I have a feeling there is a problem in how i am "$_REQUEST" variables through the post method.
Next to each user name there is a pulldown menu whose name is "rank" combine with the id number of that user
the 'rank_array' is the hidden texfield from the previous page which stores user id.
if I hard code it, and remove the fore loop, the database is updated perfectly find. However, in trying to make it more efficient I have run into this problem.
Any help is appreciated
Best,
Ed.
I believe this is proper sintax but I have a feeling there is a problem in how i am "$_REQUEST" variables through the post method.
Next to each user name there is a pulldown menu whose name is "rank" combine with the id number of that user
the 'rank_array' is the hidden texfield from the previous page which stores user id.
Code: Select all
$my_array = explode(",", $_REQUEST['rank_array']);
foreach($my_array as $value) // loop through $my_array & populate database accordingly
{
$temp_value = $_REQUEST['rank'.$value.""]; //req. rank given to this user
$sql = "UPDATE members SET rank = '".$temp_value."' where id='".$value."'";
$result = mysql_query($sql);
}Any help is appreciated
Best,
Ed.