douduan1953 2013-11-19 18:56
浏览 7
已采纳

显示搜索结果时无法删除“ARRAY”一词[关闭]

How would I remove the word 'ARRAY' from my search results. Here is the function that is performing the search. Also, I am pulling the data from a mysql db. Everything works great except the word 'ARRAY' printing on top of the results.

<?php

$sql_statement = "SELECT title, type, pubdate, isbn ";
$sql_statement .= "FROM booklib ";

if($keyword != 'ALL') {
    $sql_statement .= "WHERE title LIKE '%$keyword%' ";
}

$sql_statement .= "ORDER BY title, type, pubdate, isbn ";

$result = mysql_query($sql_statement);

$outputDisplay = "";
$myrowcount = 0;

if(!$result) {

    selectResults($statement, $db);
} else {
    if($keyword == 'ALL') {
        $outputDisplay = "<h1>Current Titles: </h1>";
    } else {
        $outputDisplay = "<h1>Current Titles that match: '$keyword'</h1>";
    }

    $outputDisplay .= list($title, $type, $pubdate, $isbn) = explode('*', $line);

    $numresults = mysql_num_rows($result);

    for($i = 0; $i < $numresults; $i++) {

        $myrowcount++;

        $row = mysql_fetch_array($result);


        $title = $row['title'];
        $category = $row['type'];
        $pub_date = $row['pubdate'];
        $isbn = $row['isbn'];

        $outputDisplay .= "<br>$myrowcount.$title";
        $outputDisplay .= "<br>Category: $category";
        $outputDisplay .= "<br>Publication Date: $pub_date";
        $outputDisplay .= "<br>ISBN: $isbn</br>";
    }

    print $outputDisplay;
    getServer();
}
  • 写回答

1条回答 默认 最新

  • douyi4991 2013-11-19 19:23
    关注

    It is this line that does it:

    $outputDisplay .= list($title, $type, $pubdate, $isbn) = explode('*', $line);
    

    Assignment operations return the value that is being assigned. explode returns an array that is assigned to the variables in list. Basically, apart from the side effect of assigning variables in list, it's as if your code was doing this:

    $outputDisplay .= explode('*', $line);
    

    If you try using an array as a string, PHP casts the array to a string that has the value "array". In addition, a notice is generated but it is probably not shown because your error_reporting setting doesn't allow output of E_NOTICE errors.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计