Jump to content

Archived

This topic is now archived and is closed to further replies.

Salis

PHP & MySQL WHERE order listing help.

Recommended Posts

I know that there are a few free Forums and BB out there but they do have their limitations, even with mods. I am working on a site that has a forum but it is a special forum.

I know PHP and MySQL. I can create every thing that I need, the control panels, register pages post pages and what not, I can even make a topic viewer but that is the problem. Basically If I make a post then some one else and after some one else another guy, but when the posts are read from the database they are not listed as they need to be. It's like this:

[i]This is how it should be[/i]

Salis: Yo, So are we ready?
The_Kid: No, not 'till tomorrow
robins-j: What's the hold up

Ok, but this is what it would look like when read from the database

The_Kid: No, not 'till tomorrow
Salis: Yo, So are we ready?
robins-j: What's the hold up

This is the code I'm using to pull the info from the DB

[code]
$query = mysql_query("SELECT * FROM posts WHERE page_id = '$id'");

while ($row = mysql_fetch_array($query))
{
  include('view_post.php');
}
[/code]

I'm guessing it's something simple but I'm not sure. Can any one help me out?

*EDIT*
I forgot to mention that I do have a posting count set as a primary and an auto incerment

Share this post


Link to post
Share on other sites
$query = mysql_query ( "SELECT * FROM posts WHERE page_id='$id' ORDER BY auto_increment_field_stuff_thingy ASC" ) ;

Replace auto_increment_field_stuff_thiny by whatever is your primary auto_increment key.

Share this post


Link to post
Share on other sites
So in my case

[code]
$query = mysql_query ( "SELECT * FROM posts WHERE page_id='$id' ORDER BY post_count ASC" );
[/code]

Thank you a lot. I figured it was something simple!

Also, I refer back to PHPfreaks for nearly all the help. Awesome Site and Community!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.