OK i am trying to display a list on a page that displays a product code, product name and a pdf file. The product_code and product_name are in the database and the pdf files are in a folder on the server. I figured out how to display the data from the data base and also how to display the files from the directory folder. Where I am having trouble is getting the 2 scripts to work together. My end result would display a link on the page that would read like this
PK-PEN: Slimeline Pen Kit Instuctions (this would be a link to the pdf for download)
In the database there is also a file table that has the name of the pdf file with a file_id and this file_id is also in the library table where i am pulling the product_code and product_name from if that helps.
Here is my code for the data display
<?php
$username="";
$password="";
$database="";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM library";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b>Pen Kits</b><br><br>";
$i=0;
while ($i < $num) {
$productcode=mysql_result($result,$i,"product_code");
$productname=mysql_result($result,$i,"product_name");
echo "<b>$productcode</b>: $productname</a><br>";
$i++;
}
?>
Here is the code for the pdf display from the directory....
<?php
$username="";
$password="";
$database="";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM library";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b>Pen Kits</b><br><br>";
if ($handle = opendir('/home/httpd/vhosts/pennstateind.com/httpdocs/library/')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<a href="'.$file.'">'.$file.'</a>';
}
}
closedir($handle);
}
?>
<P>List of files:</p>
<P><?=$thelist?></p>
My question is how do I combine these 2 and make them return the result of a list that would display a link to download the PDF file.
I am new to PHP and any help would be great. Thank you in advance a million times over!!!!!
Lou