SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jan 2001
    Location
    Ottawa ON
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am followign the tutorial on this site <i>Building a Database-Driven Web Site Using PHP and MySQL</i>. I have Apache running on my home computer (connected via @Home) with my PHP script at http://24.43.116.10/joke_delete.php

    If you are interested, I am at the "challenge" section of lesson 4. I coded my work in a different manner than the example. The example works properly and mine doesn't. The only problem that I am experiencing is that when I delete an item, it does not appear to be recycling "id" numbers. Has anyone experienced anything similar to this before. Try out the script yourself - add an item and then remove it and then try adding another item - the 'id' numbers continue to increment even though the old item has been removed.

    Will you need to see my source code (or can you make any suggestions without it). Thanks for your assistance!

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is because auto-increment fields don't work that way an auto-increment field should be used only for identifying a records with it scontents not for counting or for keeping track of the number of records you have. Why is this a problem? If you need a number next to the records upon display use a counter
    $i = 1;
    while($row = mysql_fetch_array($result)) {
    print $i;
    $i++;
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot Overgrow's Avatar
    Join Date
    Jan 2001
    Location
    Your basement
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or if you're not intending to cycle through anyway you can use:

    $countmatches = mysql_num_rows($searchresults);
    Overgrow the Government: The Edge Forums
    presented by Overgrow Marijuana Magazine

    *warning: adult content


Bookmarks

Posting Permissions

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