Jump to content

Displaying results in table help needed


pedmeister

Recommended Posts

I need help displaying the results of the query on the page below in a table please.

 

I can make them display as a text table but not as url's within the table.

 

<?
if(isset($_GET['id']))
{
include 'library/config.php';
include 'library/opendb.php';

$id      = $_GET['id'];
$query   = "SELECT name, type, size, content FROM upload WHERE id = '$id'";
$result  = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);

header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
echo $content;

include 'library/closedb.php';
exit;
}

?>
<html>
<head>
<style>
.style2 {font-family: "Courier New", Courier, mono}
.style3 {font-size: 12px}
.style4 {font-size: 18px}
</style>
<title>Download LTS Files</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="center" class="style2"><h2><strong>LTS File Repository</strong></h2></div>
<div align="center"><img src="links_2003.jpg"></div>
<div align="center" class="style2">Welcome to the online repository for Links2003 LTS files</div>
<div align="center" class="style2">Download files below</div>
<br>
<table>
<?
include 'library/config.php';
include 'library/opendb.php';

$query  = "SELECT id, name FROM upload ORDER BY name";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "Database is empty <br>";
}
else
{
while(list($id, $name) = mysql_fetch_array($result))
{
?>


<a href="download.php?id=<?=$name;?>"><?=$name;?></a> <br>

<?
}
}
include 'library/closedb.php';
?>
</table>
</body>
</html>

 

Any help greatly appreciated

 

Peds

Link to comment
https://forums.phpfreaks.com/topic/42330-displaying-results-in-table-help-needed/
Share on other sites

you can insert resultlinks thats html code into your mysql database

that link to a certain result page

 

that way when you query your database or table, you can just display the links as part of your table, straight from your database

 

another way is you can wrap your results in html and make links out of them on the page you are querying them

 

also you can't just make "magic" links or urls out of results, the url has to point somewhere

maybe another page that processes the result more and displays more details?

 

think about where you will link results and then you start thinking about linking your results to wherever you want to link them

you can insert resultlinks thats html code into your mysql database

that link to a certain result page

 

that way when you query your database or table, you can just display the links as part of your table, straight from your database

 

another way is you can wrap your results in html and make links out of them on the page you are querying them

 

also you can't just make "magic" links or urls out of results, the url has to point somewhere

maybe another page that processes the result more and displays more details?

 

think about where you will link results and then you start thinking about linking your results to wherever you want to link them

 

Ok, I understand the logic thanks. Do I need to change the db table?

 

But, how do I code that? I am new to php/mysql.

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.