The primary key which is the id is set to auto increment. Here's the code...
if($_POST['formSubmit'] == "Submit")
{
//appending the date to store in the database.
$entry_date_array = array($_REQUEST["year"],$_REQUEST["month"],$_REQUEST["day"]);
$entry_date = implode('-', $entry_date_array);
echo "$entry_date";
//appending aggr nr and fetching the id from the database.
$aggr_nr = $_REQUEST['list_nr_01'].$_REQUEST['list_nr_02'].$_REQUEST['list_nr_03'];
$sql="SELECT v.id FROM aggregatenumber AS v WHERE v.aggr_nr = '".$aggr_nr."'";//missing Quotes
$aggr_id = @mysql_query($sql);
$result = @mysql_fetch_array($aggr_id);
$test= $result['id'];
echo "$test";
$sql_einl_sp = "INSERT INTO search_parts(entry_date,aggr_nr)values('".$entry_date."','".$test."')";
$result_einl_sp = @mysql_query($sql_einl_sp);
if ($result_einl_sp == false) die("
Could not execute statement ".$sql_einl_sp);
@mysql_close();
}
Html Code
-----
<body>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<h>Save Information</h>
<input type="submit" name="formSubmit" value="Submit" />
<input type="submit" name="btncancel" value="Cancel"/>
</form>
</body>