storing and recalling file links from mysql database
Posted: Mon Feb 09, 2004 11:28 am
please tell me how or if I can do this.
i have a database with a table called numberones which has at the moment 5 fields the 5th field is named dllink I want to store a link to the file in this field so that when i query mysql it displays DOWNLOAD in the 5th column and when you click on DOWNLOAD it will download the appropriate file. below is my code for displaying the results
thanx
i have a database with a table called numberones which has at the moment 5 fields the 5th field is named dllink I want to store a link to the file in this field so that when i query mysql it displays DOWNLOAD in the 5th column and when you click on DOWNLOAD it will download the appropriate file. below is my code for displaying the results
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './'; // relative directory path to your phpBB page
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
$page_title = "inf_1_singles.php";
if ($userdata['session_logged_in'])
{
echo "Welcome ";
echo $userdata[username];
echo " you r logged in.";
include("inf_music_header.tpl");
$navbar = (int)$_GET['navbar'];
if(!isset($_GET['navbar']))
{
//$navbar = 5;
}
if ($navbar == 5)
{
include("inf_music_navbar_1950s.tpl");
}
elseif ($navbar == 6)
{
include("inf_music_navbar_1960s.tpl");
}
elseif ($navbar == 7)
{
include("inf_music_navbar_1970s.tpl");
}
$location = "localhost";
$username = "xxxx";
$password = "xxxx";
$database = "MYMUSIC";
$conn = mysql_connect("$location","$username","$password");
$year = (int)$_GET['year'];
if(!isset($_GET['year']))
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
$query = "SELECT * FROM numberones WHERE `year` = '$year'";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
echo "<table width='100%' border='1' cellpadding='2' cellspacing='2' bordercolor='#006699' align='center'>";
echo "<tr>";
echo "<td width='100%' background='./templates/fisubsilversh/images/cellpic3.gif'><div align='center' class='style2 style3'><strong>
Number 1 Singles from $year </strong></div></td>";
echo "</tr>";
echo "</table>";
echo "<table width='100%' border='1' cellpadding='2' cellspacing='2' bordercolor='#006699' align='center'>";
echo "<td width='13%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Date</div></td>";
echo "<td width='33%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Artist</div></td>";
echo "<td width='39%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Title</div></td>";
echo "<td width='6%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Wks</div></td>";
echo "<td width='9%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>d/l</div></td>";
while($row = mysql_fetch_array($result))
{
echo "<tr><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[year]</div></td></tc>";
echo "<tc><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[artist]</div></td></tc>";
echo "<tc><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[title]</div></td></tc>";
echo "<tc><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[weeksatone]</div></td></tc>";
echo "<tc><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[dllink]</div></td></tr>";
}
echo "</table>";
include("inf_music_footer.tpl");
// Release the Result Set
mysql_free_result($result);
// Close the connection
mysql_close($conn);
}
else
{
echo "You r not logged in";
}
?>