View Single Post
  #7  
Old 05-07-2008, 10:25 PM
Watdaflip's Avatar
Watdaflip Watdaflip is offline
Brigadier General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 1,643
Default Re: Updating multiple fields

All that while loop is checking for is if $query = something... which since you are using a string that stays constant its always going to be assigned at the very least
"UPDATE SET WHERE username='$username'"

Now what you need to do is count how many elements are in the array using the count() function. Then just use a for loop (or while loop if you wanted) and go through each element of the array one by one until you have gone through it count() times.

PHP Code:
$count count($array);
for(
$i=0$i $count$i++)
{
// do whatever with... $array[$i]

Also keep in mind (I don't know if this will work in your exact situation), but you can update more then one column of the same row at a time, just format your query like
PHP Code:
UDPATE table_name SET column1='value1'column2='value2'column3='value3' WHERE username='$username' 
__________________

Register/Login Script
Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Reply With Quote