Posted by "William Stokes" on 01/20/06 07:46
Hello,
The code below is from a document library I'm building. With this user can
upload a file to server and the uploaded files are printed as links to same
page. For each printed document there's a check box "Delete" for marking
that document for deletion. The document info from DB is printed using
'while' loop. The only problem I have is that I don't know how to
handle/read the Delete checkbox values because the checkbox name is
different for each file. Checkboxes are printed whit this line:"echo "<td
colspan=\"5\"><input type=\"checkbox\" name=\"del_$id\">Delete</td>";"
So. Any ideas how to resolve this or find another way to do the same task?
I'm running out of ideas. Thanks a lot! (Please see code below)
-Will
<?php
/* if document is marked for deletion run delete code here. HOW?*/
/*start the form*/
print "<form name=\"docs\" method=\"post\" action=\"$PHP_SELF\"
enctype=\"multipart/form-data\">";
/*select the old docs from DB*/
$sql="SELECT * FROM ******* ";
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
while ($num >= $cur) {
$row = mysql_fetch_array($result);
$id = $row["id"];
/*put results to vars here*/
echo "<table width=\"700\" border=\"0\" cellspacing=\"0\"
cellpadding=\"0\">";
/*print data out here */
/*mark checkbox below if you want to delete the document. $id is documents
id from database*/
echo "<tr>";
echo "<td colspan=\"5\"><input type=\"checkbox\"
name=\"del_$id\">Delete</td>";
echo "</tr>";
/*print rest of data out here */
echo "</table>";
$cur++;
}
?>
</form>
Navigation:
[Reply to this message]
|