1981tarun Posted May 10, 2010 Share Posted May 10, 2010 Hello friends, I want to use this code for download the file from the server directory. <?php include_once('config.php'); // select record from mysql $sql="SELECT * FROM files ORDER BY id ASC"; $result=mysql_query($sql); ?><table width="490px" border="0" cellspacing="1" cellpadding="0" style="text-align: left"> <tr> <td style="height: 56px"><table width="490px" cellpadding="3" cellspacing="1" class="border" > <tr> <td colspan="3" class="border_id"><strong>Download File...</strong> </td> </tr> <tr> <td align="center" class="border_id" style="width: 49px; height: 13px"><strong>Id</strong></td> <td align="center" class="border_id" style="height: 13px"><strong>Name</strong></td> <td class="border_id"></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?><tr> <td class="border_id" style="width: 49px"><? echo $rows['id']; ?></td> <td class="border_name"><? echo $rows['name']; ?></td> <td class="border_id"><a href="upload/?id=<? echo $rows['id']; ?>">Download</a></td> </tr> <? // close while loop } // close connection; mysql_close(); ?></table></td> </tr> </table> But on the Download button i want to use the hyperlink with echo and directly download the file from server directory. but i not found the code. please help me. my all data store in "upload/" folder over the server. please correct this code <a href="upload/?id=<? echo $rows['id']; ?>">Download</a> Thanks Link to comment https://forums.phpfreaks.com/topic/201227-please-correct-this-code/ Share on other sites More sharing options...
vistar86 Posted May 10, 2010 Share Posted May 10, 2010 try this: <table width="490px" border="0" cellspacing="1" cellpadding="0" style="text-align: left"> <tr> <td style="height: 56px"><table width="490px" cellpadding="3" cellspacing="1" class="border" > <tr> <td colspan="3" class="border_id"><strong>Download File...</strong> </td> </tr> <tr> <td align="center" class="border_id" style="width: 49px; height: 13px"><strong>Id</strong></td> <td align="center" class="border_id" style="height: 13px"><strong>Name</strong></td> <td class="border_id"></td> </tr> <?php include_once('config.php');?> <?php // select record from mysql $sql="SELECT * FROM files ORDER BY id ASC"; $result=mysql_query($sql); { while($rows=mysql_fetch_array($result)) echo "<tr>"; echo "<td class='border_id' style='width: 49px'>$rows['id']</td>"; echo "<td class='border_name'>$rows['name']</td>"; echo "<td class='border_id'><a href='upload/?id=$rows['id']'>Download</a></td>"; echo "</tr>"; // close while loop } // close connection; mysql_close(); ?></table></td> </tr> </table> if that doesn't work then try with dots on either sides of the rows like this: name'>.$rows['name'].</td> Link to comment https://forums.phpfreaks.com/topic/201227-please-correct-this-code/#findComment-1055677 Share on other sites More sharing options...
phpchamps Posted May 10, 2010 Share Posted May 10, 2010 I guess you want to directly download the file once user click on the download hyperlink.. if this is the case then just replace your download line by below code. <td class="border_id"><a href="upload/<? echo $rows['id']; ?>">Download</a></td> Link to comment https://forums.phpfreaks.com/topic/201227-please-correct-this-code/#findComment-1055681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.