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.

Recommended Answers

All 4 Replies

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.

<html>
<body>
<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">
<table>
<tr>
<td><img src="Logofinalcopy.gif"></td>

</tr>
</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>
    </tr></table><br/> 
    <table><tr><td> 
<tr>
	<td style="color: navy;">
		<strong>Please choose a file: </strong>
	</td> 
	<td>
		<input id="file" name="uploaded" type="file"><br>
    </td>
</tr>
<tr><td>
<input type="submit" value="Upload" name="btn" onclick="return check(),return doClear()"></td></tr>
</table>
<?php
ob_start();                                                                    
@session_start();
require_once ("check.php");
createsessions($username,$password,$userid,$projectid,$projectname,$filename,$size,$allocatedmemory,$answer,$usedmemory,$Remainingmemory,$result,$data3);
include 'connection.php';

 $sql= "select * from files where uploadedby='$_SESSION[username]' and projectname='$_SESSION[answer]' ";
 mysql_error();
    $result=mysql_query($sql);
    $num=mysql_num_rows($result);?>
<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
<tr>
<th></th> 
<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>
</tr>
 <?php
 $i=0;
while ($i < $num) {
 $f=mysql_result($result,$i,"fileid");     
$f1=mysql_result($result,$i,"filename");
$f2=mysql_result($result,$i,"uploadedby");
$f3=mysql_result($result,$i,"uploadeddate");
$f4=mysql_result($result,$i,"size");
                             
?>
 <tr>
 <td><a style="color: navy;cursor: pointer" onclick=" window.open('http://10.70.2.142/Project/download.php?f1=<?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')">
    download</a></td>
<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>
<?php
    $i++;
    }
?>
</table>


</form></body></html>

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:

<?php
	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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.