Is there a simpler way to do this that I'm missing?
Here's what I want to do:
I have this mini-site that I'm building, and it's just articles all linked from the home page. When I add a new article, I'd also like to add the link to it to the navbar on the left of all the pages. The way I built the site, the navbar is hard-coded on each page. I'm thinking if I put the articles into a MySQL database, then I could build the navbar on the fly.
Is there a simple way to do this?
Here's the site, so you can see what I've done so far.
Thanks for any help, in advance.
(Please don't laugh. I'm really new at web programming.)
why not get an article script to do the work for you automatically and it's a membership site as well that other members can submit their articles to your site sort of helping you out.
pm me if you want to see my url where I done it.
possible free article script I have in mind is articlebeach.com
or articledashboard.com
If you are familiar with php, what you can do, is rename all your files to .php instead of .html, then where the navbar links are supposed to be, put the code:
Code:
<? include("links.php"); ?>
Then create the links.php page, and in it put all the link you would like to show on each page, so that you only have to edit it once each time you add an article.
OR
If you'd rather the link add itself instead of you doing it manually, the best thing to do would be use a php-sql based article CMS as webloard suggested, there's heaps out there, just google "php article script" and I'm sure you'll find something.
What I would suggest is use BillyConnite's suggestion of including the links.php page.
But also use a database to pull the links from. Whenever you add an article, add a new row to the database with the following information: LinkID, ArticleURL, LinkText.
Then you can easily write the PHP to fetch that info and generate the navbar from this data, in fact i'll do it for you..:
Code:
<?php
require_once ('connect.php'); // connect to the database
$query = "SELECT LinkID, ArticleURL, LinkText FROM Links ORDER BY LinkID"; // Query to get the data
$result = @mysql_query ($query);
$num = mysql_num_rows ($result); // Get the amount of links the query found
if ($num > 0) { // If you got a result from your query
while ($row = mysql_fetch_array($result)) { // For each result you found, do the following
echo "<a href="$row[1]">$row[2]</a><br>"; // row[1] contains the ArticleURL, row[2] contains the LinkText
} // Ends function for while
} else { // If there were no links found in the database
echo "No links found.";
} // Ends else
mysql_close(); // Close the database
?>