Adding +1 into an ID table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
netpants
Forum Commoner
Posts: 39
Joined: Wed Nov 15, 2006 1:21 pm

Adding +1 into an ID table

Post by netpants »

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

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>
Thank you
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This post's similarity to your previous post is too high.

Image
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:3. Do not make multiple, identical posts. This is viewed as spam and will be deleted.
Locked