troubles remeving records

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg Brant

    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?i d=<?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


  • Aggro

    #2
    Re: troubles remeving records

    Greg Brant wrote:
    [color=blue]
    > so when someone views article 39 and i do
    >
    > <a href=news.php?i d=<?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[/color]

    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;

    Comment

    • Aggro

      #3
      Re: troubles remeving records

      Greg Brant wrote:
      [color=blue]
      > so when someone views article 39 and i do
      >
      > <a href=news.php?i d=<?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[/color]

      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;

      Comment

      • Greg Brant

        #4
        Re: troubles remeving records

        i want do bump all the ID's down to fill in the empty space left by
        deleating a record


        "Aggro" <spammerdream@y ahoo.com> wrote in message
        news:OKLnc.191$ uJ2.132@read3.i net.fi...[color=blue]
        > Greg Brant wrote:
        >[color=green]
        > > so when someone views article 39 and i do
        > >
        > > <a href=news.php?i d=<?php $id+1; ?> for the "next>>" button and record[/color][/color]
        40[color=blue][color=green]
        > > doesnt exist it errors
        > >
        > > how can i resort the table to suffle all the id's so there are no gaps[/color][/color]
        like[color=blue][color=green]
        > > this[/color]
        >
        > 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;[/color]


        Comment

        • Greg Brant

          #5
          Re: troubles remeving records

          i want do bump all the ID's down to fill in the empty space left by
          deleating a record


          "Aggro" <spammerdream@y ahoo.com> wrote in message
          news:OKLnc.191$ uJ2.132@read3.i net.fi...[color=blue]
          > Greg Brant wrote:
          >[color=green]
          > > so when someone views article 39 and i do
          > >
          > > <a href=news.php?i d=<?php $id+1; ?> for the "next>>" button and record[/color][/color]
          40[color=blue][color=green]
          > > doesnt exist it errors
          > >
          > > how can i resort the table to suffle all the id's so there are no gaps[/color][/color]
          like[color=blue][color=green]
          > > this[/color]
          >
          > 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;[/color]


          Comment

          Working...