Ok, having a problem with checkboxes and arrays.
Trying to take multiple items and update them all at once using a checkbox in each one keyed by a unique item number.
here's a snipet of the code...
this is the array builder and update sql
if($jump == "faq_update"):
//count number of items to loop thru
$num_rows = count($fid);
//loop thru items
for($i = 0; $i < $num_rows; ++$i):
if($display[$i] == yes):
$update = "UPDATE faqs SET question = \"$question[$i]\", answer = \"$answer[$i]\", display = \"yes\" WHERE fid = \"$fid[$i]\"";
$result = mysql_query($update) or die ("Could not update");
else:
$update = "UPDATE faqs SET question = \"$question[$i]\", answer = \"$answer[$i]\", display = \"no\" WHERE fid = \"$fid[$i]\"";
$result = mysql_query($update) or die ("Could not update");
endif;
endfor;
else:
else:
echo"
<table width = 95% border = 0 bordercolor = black cellpadding = 0 cellspacing = 0>";
$faq = mysql_query("SELECT * FROM faqs ORDER BY fid");
while($result = mysql_fetch_array($faq)):
$fid = $result["fid"];
$question = $result["question"];
$answer = $result["answer"];
$display = $result["display"];
echo"
<form action = \"$PHP_SELF?jump=faq_update&admin_dir=home\" method = post>
<input type = hidden name = fid[] value = $fid>
<tr>
<td height = 10>
</td>
</tr>
<tr>
<td height = 10 width = 100% bgcolor = 8da886 class = menu align = left valign = top>
Question:
<textarea $answer name = question[] class = faqIndexQ cols = 40 rows = 10>$question</textarea>
</td>
</tr>
<tr>
<td width = 100% bgcolor = 8da886 class = menu align = left valign = top>
Answer:
<textarea $answer name = answer[] class = faqIndexA cols = 40 rows = 10>$answer</textarea>
</td>
</tr>
<tr>
<td width = 100% bgcolor = 8da886 class = menu align = left valign = top>
Display";
if($display == yes):
echo"<input type = checkbox name = display[] class = faqcheckbox value = yes checked>";
else:
echo"<input type = checkbox name = display[] class = faqcheckbox value = yes>";
endif;
echo"
</td>
</tr>
<tr>
<td width = 100% bgcolor = 8da886 class = menu align = left valign = top>
</td>
</tr>";
endwhile;
echo"
<tr>
<td width = 100% bgcolor = 8da886 class = menu align = left valign = top>
<input type = submit class = prodButton value = \"Update\">
</td>
</tr>
</table>
</form>";
endif;
when I run this code it just doesn't act right...
Anyone have any ideas