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="comment select.php" method="post" enctype="multip art/form-data"
name="UpdateCom ments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFF F">
<tr align="center" class="ListHead ing">
<td width="20%" height="31">Cat egory</td>
<td width="60%" height="31">Com ment</td>
<td width="10%" height="31">Sha re</td>
</tr>
<tr class="BodyText ">
<?php
while($row =& mysql_fetch_arr ay($commentresu lts)) {
extract($row);
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCC CC\">\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("SE LECT * FROM commenttype WHERE username =
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_arr ay($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($availabl e); ?> </td>
</tr>
<?php
}
?>
</table>
</form>
*************** *************** *************** ***************
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="comment select.php" method="post" enctype="multip art/form-data"
name="UpdateCom ments">
<table width="100%" border="0" cellpadding="0" cellspacing="2"
bgcolor="#FFFFF F">
<tr align="center" class="ListHead ing">
<td width="20%" height="31">Cat egory</td>
<td width="60%" height="31">Com ment</td>
<td width="10%" height="31">Sha re</td>
</tr>
<tr class="BodyText ">
<?php
while($row =& mysql_fetch_arr ay($commentresu lts)) {
extract($row);
if ($i%2) {
$class = 'row1';
echo "<TR bgcolor=\"#CCCC CC\">\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("SE LECT * FROM commenttype WHERE username =
'$username'");
if (!$commenttype) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while($row1 =& mysql_fetch_arr ay($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($availabl e); ?> </td>
</tr>
<?php
}
?>
</table>
</form>
*************** *************** *************** ***************
Comment