|
Posted by Ian Davies on 07/25/06 21:29
Hello
Needing help with a suitable solution.
I have extracted records into a table under three columns 'category',
'comment' and share (the category column also holds the index no of the
record in a hidden field)
I wish the user to be able to edit the data in the table, so I have
extracted the records into hiddenfield, textareas, dropdown list and
checkbox so that they can make changes.
I named these elements as arrays and wish to run an sql to take each row in
turn (and any changes made) and update the mysql table. I did something
similar with just one record but am stuck as to how I use the arrays of a
number of form elements together
My code for the table is below but I dont know how the script should go when
the form is submitted to add each row in turn
Help greatly appreciated
Ian
**********************************************************************
<form action="commentselect.php" method="post" enctype="multipart/form-data"
name="UpdateComments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFFF">
<tr align="center" class="ListHeading">
<td width="20%" height="31">Category</td>
<td width="60%" height="31">Comment</td>
<td width="10%" height="31">Share</td>
</tr>
<tr class="BodyText">
<?php
while($row =& mysql_fetch_array($commentresults)) {
extract($row);
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCCCC\">\n";
} else {
$class = 'row2';
echo "<TR bgcolor=\"white\">\n";
}
$i += 1;
?>
<td width="20%" align="left" class="bodytext"><select
name="category[]" style="WIDTH: 90%">
<option value="<?php echo $row['TypeID']; ?>"><?php echo $row['typedesc'];
?></option>
<?php
$commenttype = mysql_query("SELECT * FROM commenttype WHERE username =
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_array($commenttype)) {
extract($row1);
?>
<option value="<?php echo $row1['TypeID']; ?>"><?php echo
$row1['typedesc']; ?><br>
</option>
<?php
}
?>
</select>
<input name="commindex[]" type="hidden" value="<?php echo $commindex;
?>"></td>
<td width="60%" align="left" class="bodytext"> <textarea
name="comm[]" rows="2" style="WIDTH: 99%"><?php echo $comment;
?></textarea></td>
<td width="10%" align="center" class="bodytext"><input type="checkbox"
name="avail[]" value="checkbox" <?php share($available); ?>> </td>
</tr>
<?php
}
?>
</table>
</form>
************************************************************
Navigation:
[Reply to this message]
|