Jump to content

[SOLVED] adding +1 to an ID table


netpants

Recommended Posts

Alright well I have a simple input form for php, its like an address book. But my problem is I didnt add an ID table to the database before, and I just added one. I need to set it up so that it automaticly adds +1 to the ID field. Look here. http://www.freegamespot.net/dancefactory/display.php

On the first column there is an ID field, I put in those IDS, but I need php to automaticly add +1 to every new entry for the ID field. Here is my code.

[code]<?
$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>[/code]

Is this correct? If not what is wrong and how do I make it add the +1 to the ID field for every new entry.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.