Log in

View Full Version : ID numbers do not increment



JRF2k
03-20-2008, 02:57 PM
Here's my form with a link to delete records from a database.


<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.

thetestingsite
03-20-2008, 04:19 PM
Change this:



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


to this:



echo '<td><a href="delete.php?id='.$id.'">Delete</a></td></tr>';


Hope this helps.

JRF2k
03-20-2008, 07:11 PM
The one thing I didn't try!

Thanks, it works now.