470,833 Members | 1,190 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

troubles remeving records

i have a news system which runs off the id of the news item,

the system allows the owner to delete a record if the wish,
this removes the record from the database taking with it that auto_incriment
ID

so i would end up with

ID
----
38
39
41
42
etc

so when someone views article 39 and i do

<a href=news.php?id=<?php $id+1; ?> for the "next>>" button and record 40
doesnt exist it errors

how can i resort the table to suffle all the id's so there are no gaps like
this
Thanks

Greg
Jul 20 '05 #1
4 1285
Greg Brant wrote:
so when someone views article 39 and i do

<a href=news.php?id=<?php $id+1; ?> for the "next>>" button and record 40
doesnt exist it errors

how can i resort the table to suffle all the id's so there are no gaps like
this


If you don't want re-order id values in your table, you could use a
query like this, to find the next id:

select min(id) from tablename where id > 39;
Jul 20 '05 #2
Greg Brant wrote:
so when someone views article 39 and i do

<a href=news.php?id=<?php $id+1; ?> for the "next>>" button and record 40
doesnt exist it errors

how can i resort the table to suffle all the id's so there are no gaps like
this


If you don't want re-order id values in your table, you could use a
query like this, to find the next id:

select min(id) from tablename where id > 39;
Jul 20 '05 #3
i want do bump all the ID's down to fill in the empty space left by
deleating a record
"Aggro" <sp**********@yahoo.com> wrote in message
news:OK***************@read3.inet.fi...
Greg Brant wrote:
so when someone views article 39 and i do

<a href=news.php?id=<?php $id+1; ?> for the "next>>" button and record 40 doesnt exist it errors

how can i resort the table to suffle all the id's so there are no gaps like this


If you don't want re-order id values in your table, you could use a
query like this, to find the next id:

select min(id) from tablename where id > 39;

Jul 20 '05 #4
i want do bump all the ID's down to fill in the empty space left by
deleating a record
"Aggro" <sp**********@yahoo.com> wrote in message
news:OK***************@read3.inet.fi...
Greg Brant wrote:
so when someone views article 39 and i do

<a href=news.php?id=<?php $id+1; ?> for the "next>>" button and record 40 doesnt exist it errors

how can i resort the table to suffle all the id's so there are no gaps like this


If you don't want re-order id values in your table, you could use a
query like this, to find the next id:

select min(id) from tablename where id > 39;

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Vladimir Ignatov | last post: by
2 posts views Thread by J-W Reuling | last post: by
3 posts views Thread by Eagle | last post: by
1 post views Thread by Ray Holtz | last post: by
reply views Thread by Michal | last post: by
1 post views Thread by Pegasus | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.