hi, i need help with a script i'm having trouble with. I have a form where a user can submit a letter from A-Z which will get inserted into mysql (class table). But what i want is, when the first user submits an "A" , it gets inserted into mysql with A1, second user will be A2 etc. (they get a class id). If a user put in "B", the first user becomes B1 and etc.
I have made 1 page which is a form page and a second page to insert the information into mysql. I can insert A but can't get it to be A1. Help!!! thanks. this is my script for the 2nd page.
<?php
include 'in.in';
set_error_handler("errorHandler");
session_start();
if (!session_is_registered("formVars"))
session_register("formVars");
if (!session_is_registered("errors"))
session_register("errors");
$errors = array();
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname] = trim(clean($value, 50));
if (!($connection = @ mysql_pconnect($hostName,
$username,
$password)))
die("Could not connect to database");
if (!mysql_select_db($databaseName, $connection))
showerror();
if (session_is_registered("loginUsername"))
{
$BREid = getBrewersID($loginUsername, $connection);
$query = "INSERT INTO wine_entries SET ".
"wine_class = \"" . $formVars["wine_class"] . "\", " .
"wine_entry = \"" . $formVars["wine_entry"] . "\", " .
"wine_year = \"" . $formVars["wine_year"] . "\", " .
"wine_name = \"" . $formVars["wine_name"] . "\", " .
"wine_ingredient = \"" . $formVars["wine_ingredient"] . "\", " .
"brewers_id = $BRid";
}
else
header("Location: login.php");
if (!(@ mysql_query ($query, $connection)))
showerror();
$wine = @ mysql_insert_id($connection);
header("Location: sert.php?wine=$wine AND brewers_id=$BREWid");
?>