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
display the contents of MySql Blog
Moderator: General Moderators
- ericburnard
- Forum Contributor
- Posts: 104
- Joined: Wed Jun 15, 2005 5:11 pm
- Location: Chesterfield, UK
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- ericburnard
- Forum Contributor
- Posts: 104
- Joined: Wed Jun 15, 2005 5:11 pm
- Location: Chesterfield, UK
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