我有一个包含一些字段的表格。地址就是其中之一。我使用 textarea 标签作为地址。现在的问题是,当我根据一个地址搜索某些东西时,它只适用于一行地址。我的意思是,如果我在地址中输入了换行符(段落格式),它不会显示结果。所有其他搜索查询都运行良好。这是我的代码,
地址下拉列表代码:
<input type="hidden" name="category_address" value="address"/>
<select name='criteria_address' style="width:100px;">
<option selected="selected"></option>
<?php
$order = "SELECT DISTINCT address FROM lh_clients ORDER BY clientname" or die (mysql_error());
$result = mysql_query($order);
while ($data = mysql_fetch_array($result)) {
echo ("<option>$data[address]</option>");
}
?>
</select>
搜索查询代码:
if (isset($_POST['criteria_address']))
{
$category_address = $_POST['category_address'];
$criteria_address = $_POST['criteria_address'];
$query = "SELECT * FROM lh_clients WHERE $category_address = '$criteria_address' ORDER BY clientname";
$result = mysql_query($query) or die(mysql_error());
$num_rows = mysql_num_rows($result);
while ($data = mysql_fetch_array($result)) { ?>
<tr>
<td style="vertical-align:top;"><? echo $data['clientname']; ?></td>
<td style="vertical-align:top;"><? echo $data['clienttype']; ?></td>
<td style="vertical-align:top;"><? echo nl2br($data['address']); ?></td>
<td style="vertical-align:top;"><? echo $data['contacts']; ?></td>
<td style="vertical-align:top;"><? echo $data['sensitivity']; ?></td>
<td style="vertical-align:top;"><? echo $data['acountmanager']; ?></td>
<td style="vertical-align:top;"><? echo $data['responsibleexecutive']; ?></td>
<td></td>
</tr>
<?php
}
}
我认为搜索查询不适用于地址中的换行符。