I have a mysql database with articles in it.
I query the database and create a list of the articles in my page.
But this list is just static content.
I want to write a script that will list the articles in the database and present them on the page as links, so that when I click on the link, it will load another page that has the contents of the article.
This seems like such a basic thing but no book I have looked at has this example.
Anyone know what code I need to write.
Here is what I have so far...
<html>
<head>
<title>List of John's United Articles</title>
</Head>
<body>
<?php
//ESTABLISH A CONNECTION
$dbcnx = @mysql_connect('localhost','root','');
if(!$dbcnx){
echo('<p>Unable to connect to the database!</p>' );
exit();
}
//SELECT A DATABASE
if(! @mysql_select_db('osheaarticles')) {
die( '<p>Unable to locate the "osheaarticles" database!</p>' );
}
?>
<p> Here are all the united articles in the database </p>
<blockquote>
<?php
//SEND SQL QUERY
$results = @('SELECT title FROM unitedarticles');
if(!$results) {
die('<p> Error performing "title FROM unitedarticles" query: '.mysql_error().'</p>');
}
while ( $row = mysql_fetch_array($results)) {
echo('<ul>'.$row['title'].'</ul>');
}
?>
</blockquote>
</body>
</html>