I am working with a form that has 2 selection box where you can select multiple values for a field, also one option needs to be able to select all the values of the field. How do I process the query in php?
I can get it to work if I select just one option, but when I go to select more than one option it doesnt work, as in no data is displayed. I also need to know if how I am trying to display the data is correct, because when I echo the variables before the query, they display fine.
If you follow the link below you will be able to see that I have two "Area Selection" boxes, that is the information that needs to be processed, sorry I cant described it better.
Html form used:
http://www.onedispatch.com/test/loadpost.html
<?php
$conn = mysql_connect("host","jarodd_admin","password");
mysql_select_db("jarodd_currentloads",$conn);
$origarea = $_POST['origin_area'];
$origarea = @implode(",", $origarea);
$destarea=$_POST['dest_area'];
$destarea=@implode(",",$destarea);
$query=("SELECT * FROM loads_now WHERE origin_state='$_POST[origin_state]' AND origin_area like '%$origarea%' AND dest_state='$_POST[dest_state]' AND dest_area like '%$destarea' AND carnum>='$_POST[carnum]'") or die(mysql_error());
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i<$num){
$originstate=mysql_result($result,$i,"origin_state");
$origarea=mysql_result($result,$i,"origin_area");
$deststate=mysql_result($result,$i,"dest_state");
$destarea=mysql_result($result,$i,"dest_area");
$carnumber=mysql_result($result,$i,"carnum");
$loaddescript=mysql_result($result,$i,"loaddescription");
$payrate=mysql_result($result,$i,"pay_rate");
$contactnum=mysql_result($result,$i,"contact_number");
?>
<tr>
<td align="center"><? echo $originstate; ?></td>
<td bgcolor=#FFFFCC align="center"><? echo $origarea; ?></td>
<td align="center"><? echo $deststate; ?></td>
<td bgcolor=#FFFFCC align="center"><? echo $destarea; ?></td>
<td align="center"><? echo $carnumber; ?></td>
<td bgcolor=#FFFFCC align="center"><? echo $loaddescript; ?></td>
<td align="center">$<? echo $payrate; ?></td>
<td bgcolor=#FFFFCC align="center"><? echo $contactnum; ?></td>
</th>
</td>
<?
$i++;
}
echo "</table>";
?>