Hexus style, news posting. Hows it done?
1)
Im currently working on a site which incorporates a database to hold the content for the site. The data on the home page shall be stored in a table called "content" The fields i have for this table include:
id, cont_title, authorid, cont_txt, cont_date
Im currently having problems segmenting the data when it is posted on the home page. Whenever i add new information to the database i simply get chunks of data all grouped together by their field names instead of being seen as single records. For example instead of each post appearing (on the home page)as:
header1
content1
header2
content2
it appears as:
header1
header2
text1
text2
i know why its doing it but i have no idea how to get around the problem. My php looks like this:
This code is inserted just under the <body> tag
PHP Code:
// Request the title of all the posts
$title = @mysql_query('SELECT cont_title FROM content');
if (!$title) {
exit('<p>Error performing query: ' .
mysql_error() . '</p>');
}
// Request the author of all the posts
$author = @mysql_query('SELECT authorid FROM content');
if (!$author) {
exit('<p>Error performing query: ' .
mysql_error() . '</p>');
}
// Request the ID and text of all the jokes
$cont = @mysql_query('SELECT id, cont_txt FROM content');
if (!$cont) {
exit('<p>Error performing query: ' .
mysql_error() . '</p>');
}
Then i add the following to display the data:
PHP Code:
<?php
// Displays the header of each post
while ($row = mysql_fetch_array($title)) { echo '' . $row['cont_title'] . '';}
// Displays the author of each post. NOTE: NO AUTHORID OR AUTHOR TABLE CURRENTLY SETUP-THIS DISPLAYS 0
while ($row = mysql_fetch_array($author)) { echo '' . $row['auhorid'] . '';}
// Displays the text of each post
while ($row = mysql_fetch_array($cont)) { echo '' . $row['cont_txt'] . '';}
?>
I believe that the ^ code is the problem since there’s no segregation of each individual record. How would i separate them so that i get some sort of posting system that hexus or neowin has?
If ive lost anyone with my explanations please say and ill try to clear my question up:)
Im using the PHP & MySql book by sitepoint. I may have mist it but i dont think that book covers what the above is stating.
PS:A minor annoyance but how do you change the date formatting in MySql tables? It's currently set to yyyy-mm-dd when i want it to be the standard british layout.