Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Dat
    Dat is offline
    Regular Coder
    Join Date
    Oct 2007
    Posts
    147
    Thanks
    28
    Thanked 0 Times in 0 Posts

    Weird Id ascending

    Look at thumbnail

    I had the script arrange it by using MYSQL_ASSOC. All entries are arranged by id perfectly from 1 to whatever+ except for ONE (Look at screenshot)

    I used this code:
    PHP Code:
    while ($row mysql_fetch_array($resultMYSQL_ASSOC)) {
    echo 
    '<tr>
    <td>'
    .$row['id'].'</td>
    <td>'
    .$row['title'].'</td>
    <td><a href="delete.php?id='
    .$row['id'].'">Delete</a></td>
    <td><a href="edit.php?id='
    .$row['id'].'">Edit
    </tr>'
    ;
    }
    } else {
    echo 
    'Sorry, but we could not retrieve any news item records.';

    Update: I looked in phpmyadmin and it gave me the same results...
    Attached Thumbnails Attached Thumbnails Weird Id ascending-screenshot.jpg   Weird Id ascending-screenshot-1.jpg  
    Last edited by Dat; 02-27-2008 at 07:23 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Have you given order by `column_name` ASC in your query?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Dat
    Dat is offline
    Regular Coder
    Join Date
    Oct 2007
    Posts
    147
    Thanks
    28
    Thanked 0 Times in 0 Posts
    Question though, why does this happen in Myphpadmin??

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    it is probably ordering by some other infomration than the ID, that is very close. For instance, if you were sorting by the date entered into the database, in nearly all cases the date entered will sort the same as teh ID ASC, but not always.

    Like suggested before, add an order clause to your query. For PHPMyAdmin, go into that table's Operations tab, and change the Alter table order by to the ID, in ASC mode.
    If I'm postin here, I NEED YOUR HELP!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •