<!doctype html>
<head>
<meta charset="utf-8" />
<link href="BlogStyle.css" rel="stylesheet" type="text/css" />
<title>The Blogging Page</title>
</head>
<?php
// Connect to the database
$database_username = 'XXXXXX';
$database_password = 'XXXXXX';
$database_host = 'XXXXXX';
$database_name = 'XXXXXX';
$connection = mysql_connect($database_host, $database_username, $database_password);
if(!$connection) { // if our attempt to connect failed
die('Could not connect: ' . mysql_error());
}
mysql_select_db($database_name, $connection); // makes other mysql_ functions act on this database
// Query our Database
?>
<body>
<form action="BlogPage.php" method="post">
<div id="pagewidth" >
<div id="header">
JonSchofield.com
</div>
<div id="wrapper" class="clearfix">
<div id="maincol">
<ul id="nav">
<li><a href="About.html">About Cars</a></li>
<li><a href="index.html">Home</a></li>
<li><a href="FAQs.html">FAQs</a></li>
<li><a href="Contact.html">Contact</a></li>
<li><a href="Gallery.html">Gallery</a></li>
<li><a href="BlogPage.php">Blog Page</a></li>
</ul>
<!-- Content goes below -->
<div id="rightcol">
<br />
SELECT Below:
<?php
$results2 = mysql_query("SELECT BLIndex, BlogHeader FROM JMWSBlog WHERE BLIndex > '13' ORDER BY BLIndex DESC");
echo "<table border='0' width=150px><tr><th>Topics</th></tr>";
while($row2 = mysql_fetch_array($results2))
{
echo "<tr><td align='left'><a href=BlogPage.php?id=" . $row2['BLIndex'] .">" . str_replace("\n", "<br />",$row2['BlogHeader']) . "</a></td></tr>";
}
echo "</table>"
?>
<br />
As and when I get the time and necessary PHP skills then I
shall add the abilty to comment on the blogs,<br />
This may take a little time, so if you are keen to pass judgement
then please use the <a href="Contact.html">Contact Page</a>.
<br />
Many thanks<br />
Jonathan.
</div>
<div id="Blog">
<span class="shadow">The Blog - Musings & Mutterings by a Malcontent</span><p />
Hello, today is <?php echo date('l, F jS, Y'); ?>.
<?php
if(isset($_GET['id'])){
$idToSearchFor=mysql_real_escape_string($_GET['id']);
$qry="SELECT DATE_FORMAT( InsertDate, '%W %D %M %Y %H:%i' ) AS InsertDate, BlogText, BLIndex, BlogHeader FROM MyBlog WHERE UserID = 'MyUser' AND BLIndex = $idToSearchFor ORDER BY BLIndex DESC";
}
else{
$qry="SELECT DATE_FORMAT( InsertDate, '%W %D %M %Y %H:%i' ) AS InsertDate, BlogText, BLIndex, BlogHeader FROM MyBlog WHERE UserID = 'MyUser' AND BLIndex > '13' ORDER BY BLIndex DESC";
}
$results = mysql_query($qry);
// OLD QUERY- $results = mysql_query("SELECT DATE_FORMAT( InsertDate, '%W %D %M %Y %H:%i' ) AS InsertDate, BlogText, BLIndex, BlogHeader FROM JMWSBlog WHERE UserID = 'MyUser' AND BLIndex > '13' ORDER BY BLIndex DESC");
// Print out our results Add this to end of query to select top 1 LIMIT 0,1
echo "<table border='0'><tr><th colspan='2'>Jonathan's Blog<hr /></th></tr>";
while($row = mysql_fetch_array($results))
{
echo "<tr>";
echo "<td><span class='shadowSmall'>" . $row['InsertDate'] . "</span></td>";
echo "<td align='right'><span class='tdTextHeader'>" . str_replace("\n", "<br />",$row['BlogHeader']) . "</span></td></tr>";
echo "<tr><td width=450px colspan='2'><br /><br />" . str_replace("\n", "<br />",$row['BlogText']) . "<br /><br />";
echo "Blog No." . $row['BLIndex'] . "<hr /></td>";
echo "</tr>";
}
echo "</table>";
// Close our connection to the database
mysql_close($connection);
?>
</div>
</div>
</div>
</form>
</body>
</html>