Note that there are some explanatory texts on larger screens.

plurals
  1. POPosting 2 Values on one mysql_query drop down
    primarykey
    data
    text
    <p>DB MAP:</p> <pre><code>Carriers "table1": carriername, carrierid, ect... Post data carrierinfo "table2": carriername, id, contact, ect... carrier list </code></pre> <p>I am using <code>mysql_query</code> from <code>table2</code> for my <code>carriername</code> drop down. Using this I am able to post a carrier name to <code>table1</code>. I am trying to use the same drop down to post the related <code>id</code> from the selcected <code>carriername</code>. So in short I need to have one drop down that displays only the Carrier names but querys both <code>carriername</code> &amp; <code>id</code> from table2. When the form is posted I need to post to the <code>carriername</code> &amp; <code>carrierid</code> to table1. Below is the drop down I am using. Please let me know how I can connect the dots and add what is needed. If its possible. </p> <pre><code> &lt;?php if (isset($_POST["submit"]) &amp;&amp; $_POST["submit"] == "Submit") { for ($count = 1; $count &lt;= 9; $count++) { $fields[$count] = ""; if (isset($_POST["field" . $count . ""])) { $fields[$count] = trim($_POST["field" . $count . ""]); //echo $fields[$count] . "&lt;br /&gt;"; } } $con = mysql_connect("", "", ""); mysql_select_db("", $con); $carrierid = mysql_real_escape_string($_POST['carrierid']); $fromzip = mysql_real_escape_string($_POST['fromzip']); $tozip = mysql_real_escape_string($_POST['tozip']); $typeofequipment = mysql_real_escape_string($_POST['typeofequipment']); $weight = mysql_real_escape_string($_POST['weight']); $length = mysql_real_escape_string($_POST['length']); $paymentamount = mysql_real_escape_string($_POST['paymentamount']); $contactperson = mysql_real_escape_string($_POST['contactperson']); $loadtype = mysql_real_escape_string($_POST['loadtype']); $date = mysql_real_escape_string($_POST['date']); $insert = "INSERT INTO Carriers (`carriername` ,`carrierid`, `fromzip` ,`tozip` ,`typeofequipment` ,`weight` ,`length` ,`paymentamount` ,`contactperson` ,`loadtype` ,`date`) SELECT carriername ,'$carrierid' ,'$fromzip' ,'$tozip' ,'$typeofequipment' ,'$weight' ,'$length' ,'$paymentamount' ,'$contactperson' ,'$loadtype', NOW()) FROM carrierinfo WHERE id = '$carrierid'"; mysql_query($insert) or die(mysql_error()); $select = "SELECT `carriername` ,`fromzip` ,`tozip` ,`typeofequipment` ,`weight` ,`length` ,`paymentamount` ,`contactperson` ,`loadtype` FROM `Carriers` ORDER BY `date` DESC;"; $result = mysql_query($select) or die(mysql_error()); } ?&gt; &lt;style ="text-align: center; margin-left: auto; margin-right: auto;"&gt;&lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="button" onclick="window.location.href='search.php';" value="Search Board" /&gt;&lt;div style="border: 2px solid rgb(0, 0, 0); margin: 16px 20px 20px; width: 400px; background-color: rgb(236, 233, 216); text-align: center; float: left;"&gt; &lt;form action="" method="post";"&gt; &lt;div style="margin: 8px auto auto; width: 300px; font-family: arial; text-align: left;"&gt;&lt;br&gt; &lt;table style="font-weight: normal; width: 100%; font-size: 12px;" border="1" bordercolor="#929087" cellpadding="6" cellspacing="0"&gt; &lt;table style="font-weight: normal; width: 100%; text-align: right; font-size: 12px;" border="1" bordercolor="#929087" cellpadding="6" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="width: 10%;"&gt;Carrier:&lt;/td&gt;&lt;td&gt; &lt;?php $con = mysql_connect("", "", ""); mysql_select_db("", $con); $query=("SELECT * FROM carrierinfo"); $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "&lt;select name='carrierid'&gt;"; while($row=mysql_fetch_array($result)){ echo "&lt;OPTION VALUE='".$row['id']."'&gt;".$row['carriername']."&lt;/OPTION&gt;"; } echo "&lt;/select&gt;"; ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width: 10%;"&gt;Load Type:&lt;/td&gt;&lt;td&gt; &lt;select name="loadtype"&gt; &lt;option&gt;&lt;/option&gt; &lt;option value="TL"&gt;Truck Load&lt;/option&gt; &lt;option value="Partial"&gt;Partial&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width: 35%;"&gt;Pick Zip:&lt;/td&gt;&lt;td&gt; &lt;input id="fromzip" name="fromzip" maxlength="50" style="width: 100%;" type="text"&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width: 35%;"&gt;Drop Zip:&lt;/td&gt;&lt;td&gt; &lt;input id="tozip" name="tozip" maxlength="50" style="width: 100%;" type="text"&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width: 35%;"&gt;Weight:&lt;/td&gt;&lt;td&gt; &lt;input id="weight" name="weight" maxlength="50" style="width: 100%;" type="text"&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width: 35%;"&gt;Length:&lt;/td&gt;&lt;td&gt; &lt;input id="length" name="length" maxlength="50" style="width: 100%;" type="text"&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width: 10%;"&gt;Equip:&lt;/td&gt;&lt;td&gt; &lt;select name="typeofequipment"&gt; &lt;option&gt;&lt;/option&gt; &lt;option value="AUTO"&gt;Auto Carrier&lt;/option&gt; &lt;option value="DD"&gt;Double Drop&lt;/option&gt; &lt;option value="F"&gt;Flatbed&lt;/option&gt; &lt;option value="LB"&gt;Lowboy&lt;/option&gt; &lt;option value="Rail"&gt;Rail&lt;/option&gt; &lt;option value="Ref"&gt;Reefer&lt;/option&gt; &lt;option value="RGN"&gt;Removable Goose Neck&lt;/option&gt; &lt;option value="SD"&gt;Step Deck&lt;/option&gt; &lt;option value="TANK"&gt;Tanker (Food, liquid, etc.)&lt;/option&gt; &lt;option value="V"&gt;Van&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width: 35%;"&gt;Contact:&lt;/td&gt;&lt;td&gt; &lt;input id="contactperson" name="contactperson" maxlength="50" style="width: 100%;" type="text"&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width: 35%;"&gt;Rate:&lt;/td&gt;&lt;td&gt; &lt;input id="paymentamount" name="paymentamount" maxlength="50" style="width: 100%;" type="text"&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p style="text-align: center;"&gt;&lt;input name="submit" value="Submit" class="submit" type="submit"&gt;&lt;input type="button" onclick="window.location.href='newcarrier.php';" value="Add Carrier" /&gt;&lt;/p&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;p style="margin-bottom: -20px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;/body&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload