濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > PHP+MySQL使用mysql_num_rows實(shí)現(xiàn)模糊查詢圖書(shū)信息功能

PHP+MySQL使用mysql_num_rows實(shí)現(xiàn)模糊查詢圖書(shū)信息功能

熱門(mén)標(biāo)簽:合肥外呼系統(tǒng)app 寶安400電話辦理 智能外呼電銷系統(tǒng) 電銷機(jī)器人-快迭智能 高識(shí)別電銷機(jī)器人 哈爾濱400電話辦理到易號(hào)網(wǎng) 沈陽(yáng)人工智能電銷機(jī)器人公司 拉薩打電話機(jī)器人 h5 地圖標(biāo)注

本文實(shí)例講述了PHP+MySQL使用mysql_num_rows實(shí)現(xiàn)模糊查詢圖書(shū)信息功能。分享給大家供大家參考,具體如下:

一、代碼

td{
 font-size:9pt;
}
.style2 {color: #FFFFFF}

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
html>
head>
meta http-equiv="Content-Type" content="text/html; charset=gb2312">
link href="style.css" rel="external nofollow" rel="stylesheet">
title>應(yīng)用mysql_num_rows()函數(shù)獲取查詢結(jié)果集中的記錄數(shù)/title>
/head>
body>
table width="609" height="134" border="1" cellpadding="0" cellspacing="0" bgcolor="#9E7DB4" align="center">
form name="myform" method="post" action="">
  tr>
   td width="605" height="51" bgcolor="#CC99FF">div align="center">請(qǐng)輸入圖書(shū)名稱
     input name="txt_book" type="text" id="txt_book" size="25" >
     nbsp;
     input type="submit" name="Submit" value="查詢">
   /div>/td>
 /tr>
/form>
 tr valign="top" bgcolor="#FFFFFF">
  td height="81">
   table width="100%" border="0" cellpadding="0" cellspacing="0">
    tr>
     td height="79" align="right" valign="top"> br>
       table width="572" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#625D59">
        tr align="center" bgcolor="#CC99FF">
         td width="46" height="20">編號(hào)/td>
         td width="167">圖書(shū)名稱/td>
         td width="90">出版時(shí)間/td>
         td width="70">圖書(shū)定價(jià)/td>
         td width="78">作者/td>
         td width="114">出版社/td>
        /tr>
        ?php
        $link=mysql_connect("localhost","root","root") or die("數(shù)據(jù)庫(kù)連接失敗".mysql_error());
        mysql_select_db("db_database13",$link);
        mysql_query("set names gb2312");
        $sql=mysql_query("select * from tb_book");
        $info=mysql_fetch_object($sql);
        if ($_POST[Submit]=="查詢"){
          $txt_book=$_POST[txt_book];
          $sql=mysql_query("select * from tb_book where bookname like '%".trim($txt_book)."%'"); //如果選擇的條件為"like",則進(jìn)行模糊查詢
          $info=mysql_fetch_object($sql);
        }
        if($info==false){ //如果檢索的信息不存在,則輸出相應(yīng)的提示信息
          echo "div align='center' style='color:#FF0000; font-size:12px'>對(duì)不起,您檢索的圖書(shū)信息不存在!/div>";
        }
        do{
       ?>
        tr align="left" bgcolor="#FFFFFF">
         td height="20" align="center">?php echo $info->id; ?>/td>
         td >nbsp;?php echo $info->bookname; ?>/td>
         td align="center">?php echo $info->issuDate; ?>/td>
         td align="center">?php echo $info->price; ?>/td>
         td align="center">nbsp;?php echo $info->maker; ?>/td>
         td>nbsp;?php echo $info->publisher; ?>/td>
        /tr>
        ?php
        }while($info=mysql_fetch_object($sql));
        ?>
      /table>
      br>
      nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;找到相關(guān)記錄nbsp;?php $nums=mysql_num_rows($sql);echo $nums;?>nbsp;條nbsp;nbsp;nbsp;nbsp;/td>
    /tr>
   /table>
  br>/td>
 /tr>
/table>
/body>
/html>

二、運(yùn)行結(jié)果

注意:這里使用mysql_num_rows() 返回結(jié)果集中行的數(shù)目。此命令僅對(duì) SELECT 語(yǔ)句有效。要取得被 INSERTUPDATE 或者 DELETE 查詢所影響到的行的數(shù)目,需要使用 mysql_affected_rows()。

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php+mysql數(shù)據(jù)庫(kù)操作入門(mén)教程》、《php+mysqli數(shù)據(jù)庫(kù)程序設(shè)計(jì)技巧總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總》

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • php基于dom實(shí)現(xiàn)讀取圖書(shū)xml格式數(shù)據(jù)的方法
  • php基于dom實(shí)現(xiàn)的圖書(shū)xml格式數(shù)據(jù)示例
  • php根據(jù)isbn書(shū)號(hào)查詢amazon網(wǎng)站上的圖書(shū)信息的示例
  • MySQL 查找價(jià)格最高的圖書(shū)經(jīng)銷商的幾種SQL語(yǔ)句
  • 簡(jiǎn)單的php購(gòu)物車代碼
  • php實(shí)現(xiàn)簡(jiǎn)單加入購(gòu)物車功能
  • PHP實(shí)現(xiàn)的購(gòu)物車類實(shí)例
  • 基于PHP+Mysql簡(jiǎn)單實(shí)現(xiàn)了圖書(shū)購(gòu)物車系統(tǒng)的實(shí)例詳解

標(biāo)簽:山東 成都 張家口 梅州 林芝 威海 巴中 泰州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PHP+MySQL使用mysql_num_rows實(shí)現(xiàn)模糊查詢圖書(shū)信息功能》,本文關(guān)鍵詞  PHP+MySQL,使用,mysql,num,rows,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PHP+MySQL使用mysql_num_rows實(shí)現(xiàn)模糊查詢圖書(shū)信息功能》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于PHP+MySQL使用mysql_num_rows實(shí)現(xiàn)模糊查詢圖書(shū)信息功能的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    玉屏| 民乐县| 刚察县| 鄂州市| 塘沽区| 察哈| 江口县| 独山县| 怀化市| 崇礼县| 新田县| 秦皇岛市| 绥宁县| 安多县| 开化县| 开阳县| 库伦旗| 德兴市| 盐山县| 平阳县| 海盐县| 富民县| 体育| 南丰县| 辰溪县| 京山县| 凤山县| 自贡市| 青川县| 渝北区| 上高县| 沅江市| 宿迁市| 阳泉市| 佛冈县| 通辽市| 洛川县| 衡阳市| 玉林市| 商洛市| 奎屯市|