我创建了一个包含多个复选框和一个包含所有 50 个状态的多个下拉列表的表单。我想从下拉表单中选择多个复选框和多个状态。我的问题当然是我......
所以当我查询我需要的信息时,它会出现空白。我可能会以错误的方式处理这一切。
<form name="search_form" method="post" action="event_list">
<table>
<tr>
<td>Venue</td>
<td><input type="checkbox" name="AAC" action="" value="AAC"/>
<label >AAC</label>
<br />
<input type="checkbox" name="AKC" action="" value="AKC"/>
<label >AKC</label>
<br />
<input type="checkbox" name="ASCA" action="" value="ASCA"/>
<label >ASCA</label>
<br />
<input type="checkbox" name="CKE" action="" value="CKE"/>
<label >CKE</label>
<br />
<input type="checkbox" name="CPE" action="" value="CPE"/>
<label >CPE</label>
<br />
<input type="checkbox" name="DOCNA" action="" value="DOCNA"/>
<label >DOCNA</label>
<br />
<input type="checkbox" name="NADAC" action="" value="NADAC"/>
<label >NADAC</label>
<br />
<input type="checkbox" name="TDAA" action="" value="TDAA"/>
<label >TDAA</label>
<br />
<input type="checkbox" name="UKC" action="" value="UKC"/>
<label >UKC</label>
<br />
<input type="checkbox" name="UKI" action="" value="UKI"/>
<label >UKI</label>
<br />
<input type="checkbox" name="USDAA" action="" value="USDAA"/>
<label >USDAA</label>
<br /></td>
</tr>
<tr>
<td style="text-align: left;">State:</td>
<td style="text-align: left;"><select name="state" id="state" multiple="multiple" size="3" onchange="setCities();">
<option value="Alabama">Alabama</option>
<option value="Texas">Texas</option>
</select></td>
</tr>
<td align="right"><input type="submit" name="search" value="Submit"></td>
</tr>
</table>
</form>
<?php
$sql=" SELECT * FROM venue_event ";
if (isset($_POST['search']) && !empty($_POST['search'])){
$search_term = mysql_real_escape_string($_POST['AAC']);
$search_term2 = mysql_real_escape_string($_POST['state']);
$search_term3 = mysql_real_escape_string($_POST['NADAC']);
$search_term4 = mysql_real_escape_string($_POST['AKC']);
$search_term5 = mysql_real_escape_string($_POST['ASCA']);
$search_term6 = mysql_real_escape_string($_POST['CKE']);
$search_term7 = mysql_real_escape_string($_POST['CPE']);
$search_term8 = mysql_real_escape_string($_POST['TDAA']);
$search_term9 = mysql_real_escape_string($_POST['UKC']);
$search_term10 = mysql_real_escape_string($_POST['UKI']);
$search_term11 = mysql_real_escape_string($_POST['USDAA']);
$sql .= "WHERE venue = '{$search_term}' ";
$sql .= "OR venue = '{$search_term3}' ";
$sql .= "OR venue = '{$search_term4}' ";
$sql .= "OR venue = '{$search_term5}' ";
$sql .= "OR venue = '{$search_term6}' ";
$sql .= "OR venue = '{$search_term7}' ";
$sql .= "OR venue = '{$search_term8}' ";
$sql .= "OR venue = '{$search_term9}' ";
$sql .= "OR venue = '{$search_term10}' ";
$sql .= "OR venue = '{$search_term11}' ";
$sql .= "AND state = '{$search_term2}'"; //if I leave this out it
works with checkbox
$sql .= "ORDER BY startdate ASC";
$result=mysql_query($sql) or die(mysql_error());
}else{
header('Location: /wordpress/venue_events'); exit();
}
?>
<?php
echo "<table>
<tr>
<th>Club Host</th>
<th>Venue</th>
<th>Event Location</th>
<th>Event Start date</th>
<th>Event End Date</th>
<th>Event Premium</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo '<td><a href="'.$row['user_url'].'" target="new" >'.$row['clubhost'].'
</a> </td>';
echo "<td>" . $row['venue'] . "</td>";
echo "<td>" . $row['city'] ." ". $row['state'] ."</td>";
echo "<td>" . $row['startdate'] . "</td>";
echo "<td>" . $row['enddate'] . "</td>";
echo '<td><a href="../download.php?f='.$row['file_name'].'" >Download Premium</a></td>';
echo "</tr>";
}
echo "</table>";
?>