Posts: 3,616
Threads: 287
Joined: Jan 2003
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...
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 394
Threads: 16
Joined: Jun 2003
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
ammit potato!
Posts: 3,616
Threads: 287
Joined: Jan 2003
Order by...what?
And is the phpMyAdmin row order effective on webpages too?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 3,616
Threads: 287
Joined: Jan 2003
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.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 394
Threads: 16
Joined: Jun 2003
make an ID column and ORDER BY ID
use regular int
ammit potato!
Posts: 3,343
Threads: 83
Joined: Mar 2003
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)
Posts: 3,616
Threads: 287
Joined: Jan 2003
Thanks all! I'm fixing now...
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 2,771
Threads: 96
Joined: Oct 2003
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.
Posts: 3,616
Threads: 287
Joined: Jan 2003
Yeah :o I guess I should do that now with all my tables...when I get around to it. :wink:
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.