Page 1 of 1
display the contents of MySql Blog
Posted: Wed Jul 13, 2005 1:17 pm
by ericburnard
Hi there. i have been trying to write a blog script and have so far managed to get it to write to my database but i dont know how to make all of the posts diplayed.
how can i do it where i can just put $subject in the right place in the template to make it post the subject??
thanks again
eric
Posted: Wed Jul 13, 2005 1:29 pm
by Burrito
need to select off the database you will. Loop the results you should. Display any fields you can.
Code: Select all
$query = "select * from myBlogTable";
$result = mysql_query($query)
or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
echo $row['subject']."<br>";
} // end while for result set
Posted: Wed Jul 13, 2005 1:52 pm
by ericburnard
That puts in all of the subjetcs tho.
i am wanting it a bit like this -
Blog entry subject ($subject)
Blog Message ($message)
$date :: [$time]
then the same again underneath for the next blog entry
thanks again
Eric
Posted: Wed Jul 13, 2005 1:58 pm
by Burrito
then inject some html you should:
Code: Select all
echo "<table>";
while($row = mysql_fetch_assoc($result)){
echo "<tr>";
echo "<td>".$row['subject']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>".$row['message']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>".date("m/d/Y", strtotime($row['date']))."</td>";
echo "</tr>";
//etc
} // end while for result set