Jump to content


Photo

PHP & MySQL WHERE order listing help.


  • Please log in to reply
2 replies to this topic

#1 Salis

Salis
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts

Posted 04 August 2006 - 02:46 PM

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:

This is how it should be

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

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

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

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


#2 CTM

CTM
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 04 August 2006 - 03:12 PM

$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.

#3 Salis

Salis
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts

Posted 04 August 2006 - 03:31 PM

So in my case

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

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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users