我需要根据表单提交值获取行。
这是我的表格
<form name="choose" method "post" t" action="search.php">
<table>
<tr>
<tr>
<td height="3">
</td>
</tr>
<td width="60">
<font1>Prof</font1>
</td>
<td>
<select name proffession on>
<option value=""></option>
<option value="doctor"><font4>Doctor</font></option>
<option value="designer">Designer</option>
</select>
</td>
</tr>
<tr>
<tr>
<td height="3">
</td>
</tr>
<td width="60">
<font1>Source</font1>
</td>
<td>
<select name source>
<option value=""></option>
<option value="x"><font4>X</font></option>
<option value="y">Y</option>
<option value="z">Z</option>
</select>
</td>
</tr>
<tr>
<tr>
<td height="3">
</td>
</tr>
<td width="60">
<font1>Location</font1>
</td>
<td>
<select name location on>
<option value=""></option>
<option value="bangalore">Bangalore</option>
<option value="delhi">Delhi</option>
</select>
</td>
</tr>
<tr>
<td>
<input name=look type=submit value=submit>
</td>
</tr>
</form>
如果有任何空字段提交,我需要获取不包括该列的行。这是我的 search.php
<?php
mysql_connect("localhost","root","");//database connection
mysql_select_db("alldata");
$qry = "SELECT * FROM data WHERE location LIKE '" . mysql_escape_string($_POST['location']) . "' And proffession LIKE '" . mysql_escape_string($_POST['proffession']) . "' And source LIKE '" . mysql_escape_string($_POST['source']) . "'";
$res = mysql_query($qry);
function mysql_fetch_all($res) {
while($row=mysql_fetch_array($res)) {
$return[] = $row;
}
return $return;
}
function create_table($dataArr) {
echo "<tr>
"; for($j = 0; $j < count($dataarr); $j++) { echo "<td>".$dataArr[$j]."
</td>
"; } echo "
</tr>
"; } $all = mysql_fetch_all($res); echo "
<table class='data_table'>
"; for($i = 0; $i < count($all); $i++) { create_table($all[$i]); } echo "</table>";
?>
但是这个脚本无法为我提供解决方案。请帮忙