hi all,
i am having a page. where we can see list of files in a table and in every row download link is there.we can download that file by clicking on download link, so now i need a delete link also which deletes the selected file by using its fileid.i tried for it. but i am not getting. so please..i need it..
Thank u.

7 Years
Discussion Span
Last Post by etftw

Can you post the code that generates this table?

In the mean time try to copy and paste the code you use for the download links but replacing the download link field with fieldid.

If you can post the code up then I will edit it for you.

<meta http-equiv="refresh" content="7">

<link rel="stylesheet" type="text/css" href="style.css"/>
<form enctype="multipart/form-data" action="upload2.php" method="post">
<td><img src="Logofinalcopy.gif"></td>

</table><br><hr style="color: red;">
<table align="right"><tr> <td></td>
        <td align="right" style="color: navy;"><strong><?php echo "Welcome ".$_SESSION[username];?>,</strong></td>
	<td style="color: navy;">
		<strong>Please choose a file: </strong>
		<input id="file" name="uploaded" type="file"><br>
<input type="submit" value="Upload" name="btn" onclick="return check(),return doClear()"></td></tr>
require_once ("check.php");
include 'connection.php';

 $sql= "select * from files where uploadedby='$_SESSION[username]' and projectname='$_SESSION[answer]' ";
<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
<th style="color: navy;">Fileid</th>
<th style="color: navy;">Filename</th>
<th style="color: navy;">Uploadedby</th>
<th style="color: navy;">Uploadeddate(Y-M-D)</th>
<th style="color: navy;">Size(in KB)</th>
while ($i < $num) {
 <td><a style="color: navy;cursor: pointer" onclick=" window.open('<?php echo $f1;?>','popup','width=550,height=400,scrollbars=no,resizable=no,toolbar=no,directories=no,location=center,menubar=no,status=no,left=370,center=0,top=300')">
<td><?php echo $f;?></td>
<td><?php echo $f1;?></td> 
<td><?php echo $f2; ?></td>
<td><?php echo $f3;?></td>
<td><?php echo $f4; ?> </td>
<!--<td><a style="color: navy;cursor: pointer"> Delete</a></td>--></tr>


i need to hav the delete link on line 66.like download on line 59.
Thanks for ur reply


Replace line 66 with this:

<td><a style="color: navy;cursor: pointer"> <a href="delete.php?id=<?php echo $f; ?>">Delete</a></td>

And then create a file called delete.php in the same directory and put this inside:

	include 'connection.php';
	mysql_query("DELETE FROM FILES WHERE fileid = ".mysql_real_escape_string($_GET['id']));

You should do some work on delete.php to make it check for appropriate errors etc. but this should get you by in the mean time until you have the time to improve it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.