Temper
07-13-2003, 09:48 PM
I have this garbled mess for code:
$query = "SELECT * FROM news ORDER BY id";
$result = mysql_query($query, $db) or die(mysql_error());
$numRows = mysql_num_rows($result);
for ($count = 0; $count < $numRows; $count++) {
$resultArray = mysql_fetch_array($result);
?>
<td width=500><font face="arial" color="#888888" size=4><b>
<? echo $resultArray["title"]; ?></b>
</td></tr>
<tr><td>
<b>By <font color="blue">
<? echo $resultArray["uname"]; ?></font>
- Posted on <? echo , $resultArray["date"]; ?></b>
</td></tr><tr><td>
<? echo $resultArray["text"]; ?>
<br><br>
</td></tr>
<?
}
?>
I am not fluent in MySQL or PHP, so I can't resolve this problem by myself, but I'm assuming mostly everyone can do this. This code outputs all of the text that I submit into my MySQL database onto my main page. It is displaying my news posts in order by the id colum of my table. ( The ID's are increasing by one each post ). So what happens is everytime I submit a post to my database, the ID number goes up by one, and on my main page, the ids and the posts are being displayed in an increasing mannar down the page. (ex. posts go 1,2,3,4,5,6 down the page). Unfortunatly for me, that puts the most recent post that I've submitted at the bottom of the page, and the last post I submitted at the top.
Now for the question:
How do I make it so that the IDs show the most recent post, or how do I make the bigger IDs show at the top of the page?
I hope that's not too confusing to follow, I'm not good at explaining things.
Also:
How do I put a set number of post per page? (Ex. have 10 news posts per page, and then at the bottom I'd put a link to an archive).
Thanks in advance.
-Temper.
$query = "SELECT * FROM news ORDER BY id";
$result = mysql_query($query, $db) or die(mysql_error());
$numRows = mysql_num_rows($result);
for ($count = 0; $count < $numRows; $count++) {
$resultArray = mysql_fetch_array($result);
?>
<td width=500><font face="arial" color="#888888" size=4><b>
<? echo $resultArray["title"]; ?></b>
</td></tr>
<tr><td>
<b>By <font color="blue">
<? echo $resultArray["uname"]; ?></font>
- Posted on <? echo , $resultArray["date"]; ?></b>
</td></tr><tr><td>
<? echo $resultArray["text"]; ?>
<br><br>
</td></tr>
<?
}
?>
I am not fluent in MySQL or PHP, so I can't resolve this problem by myself, but I'm assuming mostly everyone can do this. This code outputs all of the text that I submit into my MySQL database onto my main page. It is displaying my news posts in order by the id colum of my table. ( The ID's are increasing by one each post ). So what happens is everytime I submit a post to my database, the ID number goes up by one, and on my main page, the ids and the posts are being displayed in an increasing mannar down the page. (ex. posts go 1,2,3,4,5,6 down the page). Unfortunatly for me, that puts the most recent post that I've submitted at the bottom of the page, and the last post I submitted at the top.
Now for the question:
How do I make it so that the IDs show the most recent post, or how do I make the bigger IDs show at the top of the page?
I hope that's not too confusing to follow, I'm not good at explaining things.
Also:
How do I put a set number of post per page? (Ex. have 10 news posts per page, and then at the bottom I'd put a link to an archive).
Thanks in advance.
-Temper.