Results 1 to 3 of 3

Thread: ID numbers do not increment

  1. #1
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default ID numbers do not increment

    Here's my form with a link to delete records from a database.

    Code:
    <html>
    <body><?php
    $conn=odbc_connect('Warranty','','');
    if (!$conn)
      {exit("Connection Failed: " . $conn);}
    $sql="SELECT * FROM WarrantyInformation";
    $rs=odbc_exec($conn,$sql);
    if (!$rs)
      {exit("Error in SQL");}
    
    
    
    
    echo "<table border=1>";
    echo "<tr><th>ID</th>";
    echo "<th>Requester</th>";
    echo "<th>Owner</th>";
    echo "<th>Make/Model</th>";
    echo "<th>Serial Number</th>";
    echo "<th>Recieved</th>";
    echo "<th>Shipped</th>";
    echo "<th>Ticket Number</th>";
    echo "<th>Notes/Comments</th>";
    echo "<th>DELETE</th></tr>";
    
    
    while (odbc_fetch_row($rs))
    {
      $id=odbc_result($rs,"ID");
      $requester=odbc_result($rs,"Requester");
      $owner=odbc_result($rs,"Owner");
      $makemodel=odbc_result($rs,"MakeModel");
      $serialno=odbc_result($rs,"SerialNo");
      $received=odbc_result($rs,"Received");
      $shipped=odbc_result($rs,"Shipped");
      $ticketno=odbc_result($rs,"TicketNo");
      $notes=odbc_result($rs,"Notes");
      
      echo "<tr><td>$id</td>";
      echo "<td>$requester</td>";
      echo "<td>$owner</td>";
      echo "<td>$makemodel</td>";
      echo "<td>$serialno</td>";
      echo "<td>$received</td>";
      echo "<td>$shipped</td>";
      echo "<td>$ticketno</td>";
      echo "<td>$notes</td>";
      echo '<td><a href="delete.php?id='.$id['ID'].'">Delete</a></td></tr>';
    
    
      
    }
    odbc_close($conn);
    echo "</table>";
    ?></body>
    </html>
    The delete.php works but only when the records have the ID of 1 or 2. It is now up to 12 and when I mouseover the Delete link it just says:

    http://mysite.com/delete.php?id=1. It does this for all entries now.

    I can echo the $id variable and it is counting right. I get 12 13 14 on the screen.

    Do you guys see anything that I am missing?

    Thanks as always.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Change this:

    Code:
     echo '<td><a href="delete.php?id='.$id['ID'].'">Delete</a></td></tr>';
    to this:

    Code:
     echo '<td><a href="delete.php?id='.$id.'">Delete</a></td></tr>';
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. The Following User Says Thank You to thetestingsite For This Useful Post:

    JRF2k (03-20-2008)

  4. #3
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    The one thing I didn't try!

    Thanks, it works now.

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
  •