duanlie2709 2013-05-21 00:15
浏览 58

如何显示所有匹配的关键字

Im new in PHP and I have create a table (bookstore) really look like this

no_id | author | id_book | id_topic | quote | comments | no_page

id_book and id_topic have another table eg

table for book :

id_book | book_name

table for topic :

id_topic | topic_name

I made this sql statement for show the output in my system,but my problem is the system show only one output when submit a keyword. even though there are few similar word in the database.

"SELECT a.*, b.book_name 
   FROM bookstore AS a 
   LEFT JOIN book AS b  ON  a.id_book=b.id_book 
  WHERE quote LIKE '%".

can anyone help me how to show all match quote? i am so confuse *_*

Edit: This is my php code.

$colname_Recordset1 = "-1";
if (isset($_GET['quote'])) {
    $colname_Recordset1 = $_GET['quote'];
}

mysql_select_db($database_config, $config);
$query_Recordset1 = "SELECT a.*, b.book_name FROM bookstore a 
    LEFT OUTER JOIN book b ON a.id_book = b.id_book 
    WHERE a.quote LIKE '%'". $colname_Recordset1."%%'";

$Recordset1 = mysql_query($query_Recordset1, $config) 
    or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
  • 写回答

2条回答 默认 最新

  • 普通网友 2013-05-21 01:22
    关注

    I think, if I understand correctly, that your query should be more like:

    SELECT a.*, b.book_name 
      FROM bookstore a 
      LEFT OUTER JOIN book b ON a.id_book = b.id_book 
      WHERE a.quote LIKE '%'
    

    If you are still getting a single result (where you know there is more than one result), you need to post the PHP code you are using to extract records from the DB.

    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改