I really need your help. I have a problem on my script add.php. At the start adding an entry was ok. I added 20 entries then I deleted some entries. The id is set to primary key and auto-inc in my dbase. I deleted entries which has id value of 6,7,11,12. When I tried to add an entry I noticed that the id value assigned is 11 such as
First Name:
Last Name:
Address:
Position:
Is there somebody who knows the code for my problem and where in my script i will insert it. hope i'm not asking too much.
add.php
if($submit){
$db=mysql_connect("localhost","root");
mysql_select_db("mydb",$db);
echo "$count\n";
$sql="INSERT INTO employees (id,first,last,address,position) VALUES ('$ID','$first','$last','$address','$position')";
$result=mysql_query($sql);
echo "<font size=4 face=arial color=#330066>\n";
foreach($_POST as $name=>$value){
if ($name!='submit')
echo "$name = $value<br><br>\n";
}
echo "<font size=5 face=arial color=red>";
echo "<center>Thank you! Information has been added to database.</font>\n";
echo "<br><br><Br>\n";
echo "<form method=\"post\" action=\"$PHP_SELF\">\n";
echo "<input type=\"submit\" value=\"add again\">\n";
echo "</form>\n";
echo "<form method=\"post\" action=\"testing6.php\">\n";
echo "<input type=\"submit\" value=\"back to main\">\n";
echo "</form>\n";
}
else{
$count=1;
$db=mysql_connect("localhost","root");
mysql_select_db("mydb",$db);
$temp=mysql_query("SELECT * FROM employees");
while($myrow=mysql_fetch_array($temp)){
$count=$count+1;//test how many records have been in database.
}
echo "<Br><Br>\n";
echo "<table boarder=0><tr><td align=right>\n";
echo "<font size=4 face=arial color=#330066>\n";
echo "<form method=post action=\"$PHP_SELF\">\n";
echo " <font color=red>Your ID will be $count\n</font><br>";
echo "<input type=\"hidden\" value=$count name=\"ID\"><br>\n";
echo "First Name: <input type=\"text\" name=\"first\"><Br><Br>\n";
echo "Last Name: <input type=\"text\" name=\"last\"><Br><Br>\n";
echo "Address: <input type=\"text\" name=\"address\"><Br><Br>\n";
echo "Position: <input type=\"text\" name=\"position\"><Br><br>\n";
echo "<input type=\"submit\" name=\"submit\" value=\"add to database\">\n";
echo "</form>\n";
echo "</td></tr></table>\n";
}
?>
thanks in advance. hope you understand.
🙁