【发布时间】:2014-07-30 10:02:56
【问题描述】:
我有一张大表,想一次性搜索所有字段,但有些字段是日期,所以我创建的搜索在遇到这些字段时会失败。
在使用这种类型的搜索时,有没有办法排除某些类型的字段?
$table = 'accounts';
$condition = 'tracey';
$sql = "SHOW COLUMNS FROM accounts";
$result = mysqli_query($mysqli,$sql);
if (mysqli_num_rows($result) > 0)
{
$i=0;
while ($row = mysqli_fetch_array($result))
{
if($i==0)
{
$q="select * from ".$table." where ".$row[0]." LIKE %".$condition."%";
}
else
{
$q.=" or ".$row[0]."="." LIKE %".$condition."%";
}
$i++;
}
}
$sql = $q;
$result = mysqli_query($mysqli,$sql) or die(mysqli_error($mysqli));
$row = mysqli_fetch_array($result);
$answer = $row['phone_office'];
echo '<br><br>answer = '.$answer;
或者也许有人可以建议一种更好的方法来一次性搜索表中的所有字段?
【问题讨论】:
-
stackoverflow.com/questions/14392126/…这个链接可能对你有帮助