Hello..
I have this problem with my form.
I have a form that retrieves data from a database, where user can edit or delete the selected data if they click on the checkbox.
The deleting part works fine, however, if I click on the Edit button,the field (corresponds to the value of the checkbox) that I want to edit will get mixed up with other data that's in the same field.
The code is as below.
for($i=0; $i<$num1; $i++) {
if(mysql_result($res1,$i,'LinkType')=='W') {
$LinkTitle[$i] = mysql_result($res1,$i,'LinkTitle');
$Link[$i] = mysql_result($res1,$i,'Link');
$Descrpt[$i] = mysql_result($res1,$i,'Descrpt');
$No[$i] = mysql_result($res1,$i,'No');
echo "<tr bgcolor=#F8F8FF>";
echo "<td>rif size=2>".$i.".</td>";
echo "<form action='$PHP_SELF' method=post>";
echo "<td width=20><input type=checkbox name=FileNo value='$No[$i]'></td>";
echo "<td width=90>Link Title: </font></td>";
echo "<td width=628><input name=DocTitle type=text value='$LinkTitle[$i]' size=90></td>";
echo "<td width=65 rowspan=2> </td>";
echo "</tr>";
echo "<tr bgcolor=#F8F8FF>";
echo "<td> </td><td> </td>";
echo "<td>Link : </td>";
echo "<td><input name=DocLink type=text value='$Link[$i]' size=90></td>";
echo "</tr>";
echo "<tr bgcolor=#F8F8FF>";
echo "<td height=35> </td><td> </td>";
echo "<td valign=top>Desc : </td>";
echo "<td valign=top colspan=2><input name=DocDescrpt type=text value='$Descrpt[$i]' size=90></td>";
echo "<input type=hidden name=DocType value='W'>";
echo "</tr>";
} ?>
<tr bgcolor="#F8F8FF">
<td height=42 colspan=2> </td>
<td valign=bottom><input type="submit" name="del" value=" Delete "></td>
<td valign=bottom colspan=3 align=left><input type="submit" name="edit" value=" Edit "></td>
</tr></form>
And tjhe processing code is like this:
if($edit) {
include("../incfiles/dbinfo.php");
$query = "update $tablename set
FID='$userID',
LinkTitle='$DocTitle',
Link='$DocLink',
Descrpt='$DocDescrpt'
where No='$FileNo'";
$result = mysql_query($query);
mysql_close($dbconn);
}
else if($del){
include("../incfiles/dbinfo.php");
$query = "delete from $tablename where No='$FileNo'";
$result = mysql_query($query);
mysql_close($dbconn);
}
Can someone please help me? 🙁