how to use a link to download a file in php

I am using the following code to fill the drop-down box and select a file and download it. Its working perfect.But i tried using every file to display as link and download it on clicking the link.

echo "<form id=\"form\" name=\"psform\" action=\"download_logic.php\" method=\"post\"><label>Select File:&nbsp</label><select name=\"file\" >";
            while ($row = mysql_fetch_array($result)) {
             echo "<option  value='" . $row['location'] . "'>"  . $row['location'] . "</option>";
            }

            echo "</select></label>";
        echo"<br>";
            echo "<input id=\"submit\" type=\"submit\"  name=\"filesubmit\" value=\"Download\" />  </form>";

its giving me errors ....any help please....

I am using following code:

while ($row = mysql_fetch_array($result)) {

    echo "<a  href=\"download_logic.php?f=\". $row['location'] .\". $row['fileshare'] .\">"  . $row['fileshare'] . "</a>";

}

Here is the error in the <a> tag*** Error (unexpected T_ENCAPSED_AND_WHITESPACE)*

Answers


this should work:

echo '<a  href="download_logic.php?f='. $row['location'] .'/'. $row['fileshare'] .'">'  . $row['fileshare'] . '</a>';

Need Your Help

PHPBB re populating the form with the $_POST data after submit

forms submit populate phpbb

I'm creating a custom phpbb page. There are various text fields in the page and there is also an "add ingredient" option. If the fields are filled in with various information and then an ingredient...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.