View Full Version : Sql & php
sms1616
02-20-2009, 03:36 PM
I'm brand new to this. I want to set up a sql database, but then display the results, along with the links to point to that page. Another question I have is, is there a way instead of creating each individual webpages (links) to have a tamplate where the results from the database be automatically generated into a webpage?
fobos
02-25-2009, 09:17 PM
Well it doesnt seem like anybody is giving you a try, so i will.
Are you trying to build a navigation menu or something?
Schmoopy
02-25-2009, 09:34 PM
Depends on how you've layed out your code so far, but you'll want to make good use of:
$query = mysql_query("SELECT * FROM table");
while($row = mysql_fetch_array($query))
{
echo $row['links'];
}
Obviously that's very basic but then using "include" you can include a template with links on it that you want and have it cascade across all pages.
fobos
02-25-2009, 11:27 PM
Yeah thats pretty much what i was thinking when building the menu.
Maybe you can make it into a table.
Ex.
<?php
//conection
$query = mysql_query("SELECT * FROM table");
while($row = mysql_fetch_array($query))
{
echo"
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td><a href="\". $row['link1'].""\>Link 1</a></td>
<td><a href="\". $row['link2'].""\>Link 2</a></td>
</tr>
</table>";
}
?>
Or you could just make the links in a seperate php file and include it into your page so that way you dont have to deal with mysql and it makes it easier to change the links.
<?php
echo"
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td><a href='www.google.com'>Link 1</a></td>
<td><a href='www.dynamicdrive.com'>Link 2</a></td>
</tr>
</table>";
?>
fobos
02-25-2009, 11:29 PM
i know i put "\" after the href.... <a href ="\" in the first box
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.