|
Posted by Scott on 04/13/06 22:02
On Thu, 2006-04-13 at 06:24 -0700, maxvalery@gmail.com wrote:
> Thanks.
>
> I'll get real specific now. Suppose I have this layout in index.php:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html>
> <head></head>
> <body>
> <?php require('includes/header.php');?>
> <?php require('includes/navigation.php');?>
> <?php require('includes/left.php');?>
>
> .. some database retrieval code goes here, e.g. mysql_query ("SELECT
> ...");
>
> <?php require('includes/centerright.php');?>
> <?php require('includes/far_right.php');?>
> <?php require('includes/footer.php');?>
> </body>
> </html>
>
> How would I write the <a href> tags in the 'navigation include file' to
> point to individual pages by using the "?id=1" , "?id=2" ... "?id=n"
> method in the URL?
>
If navigation.php is going to create links based off of info that you
get from the database, you need to query the database before including
the file.
For example:
<?php
$result = mysql_query("SELECT linkID, linkName from linktable");
require('includes/navigation.php');
?>
navigation.php would then do something like this:
<?php
while($row = mysql_fetch_assoc($result)) {
echo '<a href="yourPage.php?id='.$row['linkID'].'">';
echo $row['linkName'].'</a><br />'."\n";
}
?>
Of course, if navigation.php is the only file using the results from the
database query, you might as well put the query in that file.
Scott
Navigation:
[Reply to this message]
|