firefly, it works perfect if i have just 1 award but when i have more then 1 award then it updates the database only with the last award, it only listening to the last award. So if i have 2 awards then it updates only the 2nd award and ignores the 1st one. Could u help me with this (hopefully) last problem
I have the currently code:
Code before submit:
PHP Code:
$awards=$DB_site->query("SELECT aw,awardsid,name,url,userid FROM award");
while ($award=$DB_site->fetch_array($awards)) {
if($award[aw] == "$award[awardsid]" and $award[userid] == "$user[userid]") {
$lala=" checked";
$was="1";
$kol="no";
} else {
$lala="";
$was="0";
$kol="yes";
}
echo "<tr class='".getrowbg()."'><td><input type='checkbox' name='aw[$award[awardsid]]' value='$kol'";
echo "$lala>$award[name]</td><td nowrap>";
echo "<input type=\"hidden\" name=\"all[$award[awardsid]]\" value=\"$was\">";
echo "<img src=\"$award[url]\"> </td>";
}
Code after submit:
PHP Code:
while (list($award[awardsid])=each($all)) {
$was=$all[$award[awardsid]];
$now=$aw[$award[awardsid]];
if ($now=='yes' and $was=='0') {
$DB_site->query("UPDATE award SET aw='$award[awardsid]' WHERE userid=$userid and awardsid=$award[awardsid]");
} elseif ($now!='yes' and $was=='1') {
$DB_site->query("UPDATE award SET aw=0 WHERE userid=$userid and awardsid=$award[awardsid]");
}
}