Adding +1 into an ID table
Posted: Mon Dec 18, 2006 11:07 am
So i have a database , sort of like and address book, and everything seems to be working fine, but I forgot to add the ID table to the database. So i added it and gave eatch of the entries I have already an ID number starting from 0 all the way to 6 as I have 7 entries already. Now I need to add something to the insert.php file so that it adds +1 to every new ID automaticly.
Thank you.
Here is my php code for insert.php
Thank you
Thank you.
Here is my php code for insert.php
Code: Select all
<?
$username="";
$password="";
$database="";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$id=$_POST['id'];
$date=$_POST['loggedDate'];
$first=$_POST['firstName'];
$last=$_POST['lastName'];
$birth=$_POST['birth'];
$phone=$_POST['phone'];
$streetnumber=$_POST['streetNumber'];
$streetname=$_POST['streetName'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$prize=$_POST['prize'];
++$id;
$query = "INSERT INTO Winners VALUES ('$id','$date','$first','$last','$birth','$phone','$streetnumber','$streetname','$city','$state','$zip','$prize')";
mysql_query($query);
mysql_close();
?>
<form action="insert.php" method="post">
<input type="hidden" name="id" value="<? echo $id; ?>">
Date: <input type="text" name="loggedDate"> <br>
First Name: <input type="text" name="firstName"> <br>
Last Name: <input type="text" name="lastName"><br>
Birthdate: <input type="text" name="birth"><br>
Phone Number: <input type="text" name="phone"><br>
Street Number: <input type="text" name="streetNumber"><br>
Street Name: <input type="text" name="streetName"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip Code: <input type="text" name="zip"><br>
Prize: <input type="text" name="prize"><br>
<input type="Submit">
</form>