I'm using the following code to print a Table:
Code: Select all
<?php
//Connect to MySQL Host
mysql_connect("localhost","root","root") or die(mysql_error());
echo "Connected to MySQL Server<br /><hr />";
//Connect to the Database
$db_selected = mysql_select_db("invoicedistribution");
if (!$db_selected) {
die(mysql_error("DB Connection Error"));
}
echo "Connected to MySQL Database<br /><hr />";
$result = mysql_query("SELECT * FROM test");
if (!$result) {
die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);
echo "<h1>Table: {$table}</h1>";
echo "<table border='1'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($result);
?>
2121111111
2122222222
2123333333
2124444444
In the same folder that the *.php file is located, the following files are in there as well:
2121111111.pdf
2122222222.pdf
2123333333.pdf
2124444444.pdf
I want to make links out of the first column to it's respective PDF file, but unsure how to modify my script to do this.