The First Steps In Making A Dynamic Website

Article Display Page

Now it's all well creating all these links, but what are they actually pointing to? No article.php page exists at the moment, so make a new file named that and start it off by connecting and selecting the database. You do this using the same method you have used in the previous two files. Next you need to create a query, it reads like the following:

$result = mysql_query("SELECT * FROM content WHERE ID = '$aid'", $connect);

This selects all from our table, where ID (the row we set up in our table) matches with "aid" in the URL. The final part is quite a lot similar to what we did in the previous file. It's the exact same for loop, but it displays different results.

while($row = mysql_fetch_array($result)){
		echo "<h3>" . $row['Name'] . "</h3><i>By
        " . $row['Author'] . "</i><p><b>"
        . $row['Description'] . "</b></p><p>" . $row['Body'];</p>
	}

As you can see, it has the article name, author description and body all formatted in a small way. The code is exactly the same as the last file (apart from the echoing), so really there is no explaining to do. I only want to mention that while we're still using the loop to echo the results, in this case, since you know there will only be one record returned, it is not needed. It doesn't hurt though and since most programmers like to reuse their code it becomes a habit to always do things a certain way.

Coming To An End

With everything complete now, how could you make the script better? Well, you could make search engine friendly URL's or format everything in CSS - but really it's now up to you how far you want to take everything.