php即时搜索,显示数据返回单选按钮

时间:2016-02-07 04:14:36

标签: php mysql search radio-button

我使用php构建了即时搜索。基本上我想要做的是让搜索返回的每个项目都附加一个单选按钮。当用户点击该按钮时,我希望将该项的名称存储在数组中。做这样的事情我似乎找不到太多有用的文档。这是我目前的search.php代码。

<?php

mysql_select_db("wesco");

$searchArray = explode(" ", $_POST['searchterm']);
$query = "";

foreach($searchArray as $val) {
set_time_limit(0);
ignore_user_abort(1);
$search = mysql_real_escape_string(trim($val));
if (!empty($query)) {
    $query = $query . " AND"; 
}

$query = $query . "`keywords` LIKE '%$search%'";
}

if (!empty($query)) {
$find_parts = mysql_query("SELECT * FROM `parts` WHERE $query");
}
if(empty($query)){
$searchArray = explode(" ", $_POST['searchterm']);
$query = "";

}

while($row = mysql_fetch_assoc($find_parts))
{
$name = $row['name'];

echo "<center>$name</center><br />";
}


?>

0 个答案:

没有答案