请帮我解决这个问题:
if($_POST["keyword"]) {
$keyword = $_POST["keyword"];
$keyword = trim($keyword);
$keyword_array = explode(" ",$keyword);
$numberofwords = (integer)count($keyword_array);
require("server.php");
$link = open_koneksi();
$tbl_name = "author";
$query = "SELECT COUNT(*) as num FROM $tbl_name WHERE " ;
for ($x = 0; $x<= $numberofwords; $x++) {
$query .= "author LIKE '%$keyword_array[$x]%'";
if ( $x < $numberofwords ) {
$query .= " AND ";
}
}
echo("<SCRIPT>document.location.href='?p=result';</SCRIPT>");
}
如果程序段中的代码被执行,会出现如下警告:
Notice: Undefined offset: 1 in C:\xampp\htdocs\bijang\result.php on line 111
故障位置参考这段代码:
$query .= "author LIKE '%$keyword_array[$x]%'";
我该如何解决?