linking to data in MySQL DB
Posted: Wed Mar 03, 2004 12:24 am
I'm trying to make an archive page for my simple blog I wrote, What I would like is to have the archive page consist of two pages..
Page one:
should just display the links and I have this part figuared out..
Where I run into my problem is with page two
Page two:
Should just display the single blog entry based on the link that was clicked I know how to pass data from one page to another but I can't figuare out how to make the page two just show the blog entry that was clicked.. Any ideas?
I hope that this post is clear I'm not good at explaining myself.. Sorry, Also thanks for any help you provide me with..
Page one:
should just display the links and I have this part figuared out..
Code: Select all
<ul>
<?
//Get Settings
include("config.inc.php");
/* Connecting to MySQL*/
$connection = mysql_connect($db_host,$db_user,$db_pass)
or die("Could not connect to mysql. Fix me!?!");
/* Select Database. */
$db = mysql_select_db($database_name,$connection) or die("ERROR: I couldn't select the database requested!");
//Time choices
if ($UStime==us) {
//date format
$sql = "SELECT DATE_FORMAT(date, '%M %e, %Y @ %h:%i %p') AS readable_date,topic,entry,ID FROM $tablename order by date desc";
$sql_result = mysql_query($sql, $connection) or die("Query failed. Please contact the site administrator, and bitch at him.");
/*setting up array and defining result values */
while ($row = mysql_fetch_array($sql_result)) {
//defining variables, readable_date is temp field
$date = $row["readable_date"]; //date
$topic = $row["topic"]; //Title of blog entry
$id = $row["ID"]; //ID of blog entry
//Display links
echo ="<li><a href='archive2.php'>$date - $topic</a></li>";
}
/* Free resultset */
mysql_free_result($sql_result);
/* Closing connection */
mysql_close($connection);
}
?>Page two:
Should just display the single blog entry based on the link that was clicked I know how to pass data from one page to another but I can't figuare out how to make the page two just show the blog entry that was clicked.. Any ideas?
I hope that this post is clear I'm not good at explaining myself.. Sorry, Also thanks for any help you provide me with..