Hi All,
Can one of the gurus out there help me to convert a row variable to a link that will download an MP3 file?

Using the code below: my $row displays the url in plain text. I would like to create a button to initiate an automatic download command while hiding the actual url.

Thanks in advance.

$sql = "select * from mp3_library, customer_orders where (email='$email' and (customer_orders.item1=mp3_library.code or customer_orders.item2=mp3_library.code or customer_orders.item3=mp3_library.code or customer_orders.item4=mp3_library.code or customer_orders.item5=mp3_library.code))";

$result= mysql_query($sql) or die(mysql_error());

echo "<table border='0'>
<tr>
</tr>";

while($row = mysql_fetch_assoc($result)) 

{ 
echo "<tr>"; 
echo "<td>" . $row['artist'] . "</td>";
echo "<td>&nbsp;<td>";
echo "<td>" . $row['track'] . "</td>";
echo "<td>&nbsp;<td>";
echo "<td>" . $row['link']  . "</td>";
echo "</tr>"; 
} 

echo "</table>"; 

?>

Recommended Answers

All 2 Replies

Member Avatar for Rkeast

Javascript button :)

...
echo "<td>&nbsp;<td>";
echo "<td><form><input type='button' name='download' value='Download File' onclick='window.location = \"".$row['link']."\"' /></form></td>";
echo "</tr>"; 
...

Thank you Rkeast!
We're very close on this and I appreciate your contribution. The only problem that I have left is that when you ckick the download button, the mp3 plays. I need it to download to the user's computer.

Any suggestions?
Thanks again

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.