Hi, I am trying to create a form which builds up a list of parts one by one via a dropdown or textfield and then enters the whole list into a database.
<?
include "variables.php"; //
if (!$addpart){ //theyve not pressed submit
$db = mysql_connect("$dbserver","$dbuser","$dbpass");
//do the query to get the info
$result = mysql_db_query("$dbname","select * from vehicles where vid=1",$db);
//grab the row data into variables
$vid = mysql_result($result,0,"vid");
$cid = mysql_result($result,0,"cid");
$reg = mysql_result($result,0,"reg");
$make = mysql_result($result,0,"make");
$model = mysql_result($result,0,"model");
?>
<form action="<?= $PHP_SELF; ?>" method="POST">
<tr>
<td width="20%" align="left" bgcolor="<? echo $fieldbgcolor?>" valign="top"><b><font size="2" face="<? echo "$fieldfont"?>"><? echo $textbasic[27] ?></font></b></td>
<td width="80%" align="left" valign="top"> <font size="2" face="<? echo "$fieldfont"?>">
<select name="partname1">
<option selected><? echo $textbasic[21] ?></option>
<?
$db = mysql_connect("$dbserver","$dbuser","$dbpass");
@$outcome=mysql_query("SELECT * FROM parts where make='$make' and model = '$model' OR make ='' and model = ''");
require("failure.php");
while ($access=mysql_fetch_array($outcome))
{
$partname1=$access["partname"];
$partselected=$access["partname"];
echo "<option value=\"$partselected\">$partselected</option>";
}
?>
</select>
<font size="3" face="<? echo "$fieldfont"?>"><b>£ <font size="2" face="<? echo "$fieldfont"?>"><input type="text" name="partcost1" size="7" maxlength="255">
</font></td>
</td></tr>
<input type="submit" value="addpart">
<?
$partcost1 = $_POST['partcost1'];
$partname1 = $_POST['partname1'];
?>
<form>
<?
}else{ //addpart has been pressed
if ($partname1== "$textbasic[21]" ){$partname1 ="";}
$parts = array("parts" => array($partname1 , $partcost1));
print_r($parts);
}
?>
The first 2 querys are executed ok and the drop down is populated..
What is falls over is when i add the setected part to the array.
Thankyou for any help...