So I'm trying to create an ID Based Navigation system that pulls content from my DB. What I want to do is if someone enters the page at like news.php. It displays a list of posts that pulls from the DB. If you click a link it'll select that ID from the DB and display the content. (IE news.php?newsID=2). Then it would just show the content for the newsID that is "2". Following me?
Here's my code...
<?
// Include config file
include('db.php');
$link = dbConnect();
if(isset($_GET['newsID']))
{ $result = mysql_query("SELECT title, posted, body FROM news WHERE newsID = '{$_GET['newsID']}'");
$row = mysql_fetch_array($result);
// print full story here
}
else
{ $result = mysql_query("SELECT newsID, posted, title FROM news ORDER BY posted DESC");
while($row = mysql_fetch_array($result));
{ $posted = strftime("%m/%d/%y", $row['posted']);
$newsID = $row['newsID'];
print "<a href=\"index.php?newsID=$newsID\">" . htmlspecialchars($row['title']) . "</a> posted $posted<br>";
}
}
// Close link to MySQL server
mysql_close($link);
?>
So instead of working like it's suppoesed to it's printing this out to my browser...
If you would like to see for yourself check out...
http://www.evanbartlett.com/test/
So for one it's not doing the complete thing I was hoping and the dates WAY off. Anyone got any ideas of how to help me on this? I'd really appreciate it!