Qbasicnews.com

Full Version: Urgent MySQL+PHP problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay, on The Geekery, I use a database for the News. I'm adding News entries with phpMyAdmin.
The problem is that phpMyAdmin isn't adding rows in the correct order. For instance, the first bit of news was on Feb 05. Fine. Then the second bit of news I added was inserted onto the top of the table! Then the next, right in between the other ones, and then the next, Right after the one before.
How can I force phpMyAdmin to add all rows to the end of the table?
This is kind of urgent...
the way phpmyadmin displays its rows is based on the order of the first column. if you want it to show things in your order, ad an auto-incrementing int row for an id. good idea for the page too, makes it easier to sort things out. you could always click on a column's name, like "date" and it'll sort by that column for you.

ooh, and don't forget to use "order by" in your sql! don't rely on the table to order your stuff automatically
Order by...what?
And is the phpMyAdmin row order effective on webpages too?
Okay, how do I use auto_increment? It gives me a mysql error when I try to make a field called row_id, type BIGINT, auto_increment.
make an ID column and ORDER BY ID

use regular int
ALTER TABLE news ADD news_id INT AUTO_INCREMENT PRIMARY KEY

...

SELECT * FROM news ORDER BY news_id DESC

or

SELECT * FROM news ORDER BY date_added DESC (you don't have to do the ALTER TABLE this way)

(drop the DESC if you want the rows outputted in the other order)
Thanks all! I'm fixing now...
Zack: Its always good practice to have a Primary ID number. This keeps all your records unique and allows easy sorting of them from the date they were created.
Yeah :o I guess I should do that now with all my tables...when I get around to it. :wink: