Jump to content

please correct this code


1981tarun

Recommended Posts

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.