Forum Moderators: coopster
I am having trouble passing a variable which is pulled from a database entry:
<tr>
<td>Name:</td>
<td><select name="NameID"><option value="notset">- Select Name -</option> '; //--- CREATE SELECT ---
$sql = "SELECT DISTINCT * FROM ArchType ORDER BY Name";
$squig = mysql_query($sql) or die($sql . '<br />' . mysql_error());
while ($row = mysql_fetch_array($squig)) {
echo '<option value="' . $row['TypeID'] . '">' . $row['Name'] . '</option>
';}; echo '</select></td>
</tr>
When I select the Name variable, I insert it into a MySQL table:
$sqlquery = "INSERT INTO aka (NameID, akaName) VALUES('". $_POST['NameID'] ."', '". $_POST['akaName'] ."')";
$queryresult = mysql_query($sqlquery) or die(" Could not execute mysql query 1!");
$sqlquery = "SELECT * from aka"; So far so good. Variables pass and get inserted. But I want to also insert the ID (not the NameID) that comes from ArchType.. so if the name 'Bob' gets inserted into table 'aka', I want to also insert the ID from the table where all the names are stored. I know how to do the MySQL part, but I am at a loss of how to grab the ID from one table and insert it as a variable in a second.
Is this even possible?
Thank you
if the have primaryID name ID..
<tr>
<td>
echo '
<input type="hidden" size="6" name="MyID" value="'.ID.'">';
</td>
</tr>onsubmit:
$sqlquery = "INSERT INTO aka (ID,NameID, akaName) VALUES(, '". $_POST['MyID'] ."','". $_POST['NameID'] ."', '". $_POST['akaName'] ."')";