国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

PHP+MYSQL多條件選一通用搜索系統(tǒng)功能單文件7KB

這篇具有很好參考價(jià)值的文章主要介紹了PHP+MYSQL多條件選一通用搜索系統(tǒng)功能單文件7KB。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

PHP+MYSQL多條件選一通用搜索系統(tǒng)功能單文件7KB,php

通用功能: 快速填寫參數(shù)用于自己的mysql數(shù)據(jù)表搜索,ajax載入數(shù)據(jù)文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-857412.html

<?php
header("content-Type: text/html; charset=UTF-8");
//error_reporting(0);

$dbhost = "localhost";	//數(shù)據(jù)庫(kù)地址本地localhost
$dbuser = "chalidecom";	//數(shù)據(jù)庫(kù)賬號(hào)
$dbpass = "7b4ZEGJTKy";	//數(shù)據(jù)庫(kù)密碼
$dbname = "chalidecom";	//數(shù)據(jù)庫(kù)名稱
$dbport = "3306";		//數(shù)據(jù)庫(kù)端口號(hào)
$dbcode = "UTF8";		//數(shù)據(jù)庫(kù)編碼  UTF8 GB2312
$biao = "chafenba";    //數(shù)據(jù)表名稱

$pagesize = 10;		//每頁(yè)數(shù)量
$maxp = 10;		//最大顯示頁(yè)數(shù)
$title = "某某查詢系統(tǒng)";		//頁(yè)面標(biāo)題

$b = array();

$b[$biao]["name"]= "成績(jī)表"; //表格名稱
$b[$biao]["duan"]= "姓名,學(xué)號(hào),身份證號(hào),科目1,科目2,科目3,科目4,科目5,科目,科目N";//顯示字段
$b[$biao]["sox"] = "姓名,學(xué)號(hào),身份證號(hào)";//查詢條件

/*
//可以連續(xù)多組以上數(shù)據(jù)用于多表
$b["biao2"]["name"]= "其他表"; //表格名稱
$b["biao2"]["duan"]= "姓名,學(xué)號(hào),身份證號(hào),科目1,科目2,科目3,科目4,科目5,科目,科目N";//顯示字段
$b["biao2"]["sox"] = "姓名,學(xué)號(hào),身份證號(hào)";//查詢條件
*/

$biao = (isset($_GET['biao']))?addslashes($_GET['biao']):$biao;
if($_GET['Act']=="cha"){
$stime=microtime(true);
$biao = (isset($_POST['biao']))?addslashes($_POST['biao']):$biao;
$search = (isset($_POST["rame"]))?addslashes($_POST["rame"]):'';
$sort = (isset($_POST['sort']))?addslashes($_POST['sort']):"id";//
$order = (isset($_POST['orda']))?addslashes($_POST['orda']):"desc";
$duan = (isset($_POST['duan']))?addslashes($_POST['duan']):"";
$iduan = $b[$biao]["duan"]; $sox = $b[$biao]["sox"];
 $duanx=explode(",", $iduan);
 $duans = "`".join("`,`",$duanx)."`";
 $soxs=explode(",", $sox);
if (!$b[$biao]) exit("該表【{$biao}】不可查(未授權(quán))!"); 
if (!stristr("-desc-asc-","-$order-")) $order = "DESC";
if (!stristr(",$iduan,","-$sort-")) $sort=$soxs[0]; //排序字段:條件1
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($conn->connect_error) { die("Conn.Error: " . $conn->connect_error);}
$sql = "SELECT $duans FROM `{$biao}` ";
$tips = "字段[{$duan}]";
$sqlw = "WHERE `{$duan}` LIKE '%$search%' ";
$sql .= "$sqlw ORDER BY $sort $order ";
$sqc = "SELECT COUNT($sort) AS count FROM `{$biao}` $sqlw ";
$result = $conn->query($sqc);
if (!$result) exit("連接失敗信息:".mysqli_error($conn));
$row = $result->fetch_assoc();
$count = $row["count"];
if($count<1) exit("查 表[$biao] => $tips => 關(guān)鍵詞[$search]無(wú)結(jié)果");
$pagecount = ceil($count / $pagesize);
$page = 1;
if (isset($_POST["page"])) { $page = $_POST["page"];}
if ($page < 1) { $page = 1;}
if ($page > $maxp) { exit("[Most <b>$maxp</b> Page]");}
if ($page > $pagecount) { $page = $pagecount;}
if ($pagecount > $maxp) { $pagecount = $maxp;}
$start = ($page - 1) * $pagesize;
$end = $start + $pagesize;
$sql .= " LIMIT $start, $pagesize";
$result = $conn->query($sql);
if (!$result) exit("連接失敗信息:".mysqli_error($conn));
echo "<table cellspacing=\"0\">";
foreach ($result as $i=>$row) {
if(!$isti){
echo "<tr class='tt'>\r\n<th>".join("</th>\r\n<th>",array_keys($row))."</th>\r\n</tr>\r\n";
$isti="Y";
}
 echo "<tr>\r\n<td>".join("</td>\r\n<td>",$row)."</td>\r\n</tr>\r\n";
}
echo "</table>";
$etime=microtime(true);
$total = $etime-$stime;
echo "<p>結(jié)果: $count, 頁(yè)數(shù): $pagecount 耗時(shí): ".round($total,3)." \r\n";
if ($page > 1) { echo "<a href='#' onclick=\"show(1,'');\">首頁(yè)</a> ";}
for ($i = 1; $i <= $pagecount; $i++) {
 if($i == $page){ echo "$i ";}else{ echo "<a href='#' onclick=\"show($i,'');\">$i</a> ";}
}
if ($page < $pagecount) { echo "<a href='#' onclick=\"show($pagecount,'');\">尾頁(yè)</a> ";}
if($count> $maxp*$pagesize) echo "結(jié)果{$count}較多:推薦優(yōu)化輸入!";
echo "</p>";
$conn->close();
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo $title; ?></title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:Arial,sans-serif;font-size:14px;line-height:1.5;background-color:#eee}
header{display:flex;justify-content:space-between;align-items:center;background-color:#333;color:#fff;padding:5px 10px;}
.logo{font-size:16px;}
a {text-decoration:none;}
p{color:green;} b{color:blue;}
nav ul{display:flex;}
nav li{list-style:none;margin-left:10px;}
nav a{color:#fff;text-decoration:none;padding:5px;}
nav a:hover{background-color:#fff;color:#333}
.search{display:flex;justify-content:space-between;align-items:center;background-color:#fff;padding:10px;margin:10px 0;}
.search select{flex:1;padding:4px;}
.search input{flex:5;padding:5px;border:1px solid #ccc;margin-right:5px;}
.captcha{flex:2;display:flex;border:1px solid #ccc;align-items:center;margin-right:5px;}
.captcha input{border:0;padding:5px;margin-right:0px;}
.captcha img{height:22px;}
button{flex:1;background-color:#333;color:#fff;border:none;padding:4px 6px;cursor:pointer;}
button:hover{background-color:green;color:white;}
.content{background-color:#fff;padding:10px;min-height:360px;margin-bottom:88px;overflow-x:auto;}
.description{font-weight:bold;margin-bottom:10px;}
table{width:100%;border-collapse:collapse;}
table td,table th{padding:10px 0;border:1px solid #ccc;}
table th{background-color:#ddd;font-weight:bold;}
footer{display:flex;justify-content:space-between;font-size:12px;align-items:center;background-color:#333;color:#fff;padding:5px;position:fixed;bottom:0;width:100%;}
.footer div{margin-right:20px;}
.right a{color:#fff;text-decoration:none;}
.right a:hover{text-decoration:underline;}
@media screen and (max-width:656px){.search select,.search input,.search captcha,.search button{display:block;width:99.9%;}
}
</style>
</head>
<body>
  <header>
    <div class="logo"><?php echo $title; ?></div>
    <nav>
      <ul>
<?php
foreach ($b as $tt=>$vvv) {echo "<li><a href=\"?biao=$tt\">{$vvv["name"]}</a></li>\r\n";}
?>
      </ul>
    </nav>
  </header>
  <div class="search">
<select name="duan" id="duan" onchange="show(1,'');">
<?php
$sox = $b[$biao]["sox"];
$soxs=explode(",", $sox); $ia = count($soxs);
for($ii=0; $ii<$ia; $ii++){
$duen=$soxs[$ii]; echo "<option value=\"$duen\">$duen</option>\r\n";
}
?>
</select>
    <input type="text" id="rame" placeholder="輸入關(guān)鍵詞" onfocus="this.select();">
    <button onclick="show(1,'');">立即查找</button>
  </div>
<div class="set" style="display:none;">
  <input type="hidden" id="biao" value="<?php echo $biao; ?>">
  <input type="hidden" id="page" value="1">
  <input type="hidden" id="sort" value="id">
  <input type="hidden" id="orda" value="DESC">
  <input type="hidden" id="Act" value="cha">
</div>
  <div class="content">
  <div class="description">查詢結(jié)果</div>
  <div id="UpTip"></div>
  </div>
  <footer>
    <div class="left">版權(quán)所有 ? 2021</div>
    <div class="mid">備案號(hào):123456789</div>
    <div class="right"><a href="#">鏈接右</a></div>
  </footer>
</body>
<script>
function $(objId){ return document.getElementById(objId);}
var timer = null;  //延時(shí)1秒自動(dòng)查,延時(shí)與中文輸入節(jié)能
var Inputs = document.querySelector('#rame');
Inputs.addEventListener('input', function(e) {
 var keyword = e.target.value;
  if (timer) { clearTimeout(timer);}
  timer = setTimeout(function() { show(1,keyword); }, 1000);
});
function show(page,key){
$("page").value = page;
if(key != "") $("rame").value = key;
var fd = new FormData();
fd.append('rame',$("rame").value);
fd.append('biao',$("biao").value);
fd.append('orda',$("orda").value);
fd.append('page',$("page").value);
fd.append('sort',$("sort").value);
fd.append('duan',$("duan").value);
fd.append('Act',$("Act").value);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
$('UpTip').innerHTML=xhr.responseText;
}
}
};
xhr.open('POST','?Act='+$("Act").value+'&t='+new Date(),true);
xhr.send(fd);
}
</script>
</html>

到了這里,關(guān)于PHP+MYSQL多條件選一通用搜索系統(tǒng)功能單文件7KB的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • find命令——根據(jù)路徑和條件搜索指定文件

    find命令的功能是根據(jù)給定的路徑和條件查找文件或目錄,可以使用的參數(shù)很多,并且支持正則表達(dá)式,結(jié)合管道符后能夠?qū)崿F(xiàn)更加復(fù)雜的功能,是系統(tǒng)管理員和普通用戶日常工作必須掌握的命令之一。 find命令是對(duì)磁盤文件系統(tǒng)進(jìn)行搜索,因此在服務(wù)器負(fù)載較高時(shí),不建議使

    2024年02月07日
    瀏覽(19)
  • Linux[find命令]-根據(jù)路徑和條件搜索指定文件并刪除

    Linux[find命令]-根據(jù)路徑和條件搜索指定文件并刪除

    find命令:用于根據(jù)給定的路徑和條件查找相關(guān)文件或目錄,參數(shù)靈活方便,且支持正則表達(dá)式,結(jié)合管道符后能夠?qū)崿F(xiàn)更加復(fù)雜的功能。 基本語(yǔ)法格式:find pathname -options 搜索內(nèi)容 [其他選項(xiàng)] pathname:用來(lái)指定搜索路徑。 options:用來(lái)指定搜索內(nèi)容。 搜索內(nèi)容:用來(lái)指定搜索

    2024年02月05日
    瀏覽(97)
  • PHP手術(shù)麻醉信息系統(tǒng)的功能作用

    PHP手術(shù)麻醉信息系統(tǒng)的功能作用

    手術(shù)麻醉信息系統(tǒng)源碼 手術(shù)麻醉信息系統(tǒng)的使用,很大程度上方便了麻醉科醫(yī)生的日常工作,使麻醉工作流程更規(guī)范,為麻醉醫(yī)生工作提供了一個(gè)新平臺(tái)。下面簡(jiǎn)述一下該系統(tǒng)在日常麻醉工作中的作用。 ? (一) 及時(shí)合理地安排手術(shù) 麻醉信息系統(tǒng)與醫(yī)院現(xiàn)有信息系統(tǒng)“無(wú)縫”

    2024年02月14日
    瀏覽(20)
  • wordpress合理利用wp-config.php文件小功能

    這里有幾個(gè)通過(guò)往wp-config.php中添加代碼實(shí)現(xiàn)相關(guān)功能的技巧分享給大家。 1,去掉WordPress的歷史修訂版本功能。 這個(gè)是WordPress默認(rèn)的功能,主要是方便多人協(xié)作寫文章使用,但是在單人網(wǎng)站上,這個(gè)功能基本上是雞肋。 去掉的辦法: 在wp-config.php中添加代碼: 復(fù)制代碼 代碼

    2023年04月23日
    瀏覽(23)
  • 學(xué)生信息管理系統(tǒng)(php+mysql)

    學(xué)生信息管理系統(tǒng)(php+mysql)

    本系統(tǒng)是較為簡(jiǎn)單的一個(gè)可以完成 學(xué)生信息、學(xué)生成績(jī) 的增刪改查,按照 班級(jí)學(xué)科查詢 學(xué)生成績(jī),查看所有表單,簡(jiǎn)單的完成 學(xué)生選課與刪除 , 查詢考課名單 等功能。 本系統(tǒng)為本人的期末大作業(yè),所以有很多有待修改的bug以及很多有待優(yōu)化的功能。 1.主界面(index.php)

    2024年02月03日
    瀏覽(28)
  • 2023最新多功能XL軟件庫(kù)APP源碼+PHP后端系統(tǒng)源碼/功能強(qiáng)大/軟件庫(kù)自帶后臺(tái)管理系統(tǒng)

    2023最新多功能XL軟件庫(kù)APP源碼+PHP后端系統(tǒng)源碼/功能強(qiáng)大/軟件庫(kù)自帶后臺(tái)管理系統(tǒng)

    2023最新多功能XL軟件庫(kù)APP源碼+PHP后端系統(tǒng)源碼/功能強(qiáng)大/軟件庫(kù)自帶后臺(tái)管理系統(tǒng)31xl軟件庫(kù)最新可以正常使用版: https://url11.ctfile.com/d/25976711-57801726-b66bb0?p=6724 (訪問(wèn)密碼:6724) 多功能軟件庫(kù),支持自定義對(duì)接易支付 ? 安裝教程: ? 先導(dǎo)入sql數(shù)據(jù)庫(kù),然后修改config.php 里邊填

    2024年02月10日
    瀏覽(53)
  • 無(wú)涯教程-PHP - 條件判斷

    if... else if ... else 和 switch 語(yǔ)句用于根據(jù)不同條件進(jìn)行判斷。 您可以在代碼中使用條件語(yǔ)句來(lái)做出決定, PHP支持以下三個(gè)決策語(yǔ)句- if ... else 語(yǔ)句? ? ? ? ? -? ?如果要在條件為真時(shí)執(zhí)行,而在條件不為真時(shí)執(zhí)行另一個(gè)代碼,請(qǐng)使用此語(yǔ)句 elseif ?語(yǔ)句? ? ? ? ? ? ? -? 與 i

    2024年02月12日
    瀏覽(42)
  • PHP8條件控制語(yǔ)句-PHP8知識(shí)詳解

    PHP8條件控制語(yǔ)句-PHP8知識(shí)詳解

    我們昨天說(shuō)了流程控制的結(jié)構(gòu)有順序結(jié)構(gòu)、選擇結(jié)構(gòu)和循環(huán)結(jié)構(gòu)。選擇結(jié)構(gòu)就是條件結(jié)構(gòu)。 條件控制語(yǔ)句就是對(duì)語(yǔ)句中不同條件的值進(jìn)行判斷,進(jìn)而根據(jù)不同的條件執(zhí)行不同的語(yǔ)句。 在本文中,學(xué)習(xí)的是if語(yǔ)句、if…else語(yǔ)句、if…elseif語(yǔ)句和switch語(yǔ)句。 1、if語(yǔ)句 if語(yǔ)句是最為

    2024年02月14日
    瀏覽(30)
  • 基于PHP+MySQL倉(cāng)庫(kù)管理系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)

    基于PHP+MySQL倉(cāng)庫(kù)管理系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)

    PHP:MySQL倉(cāng)庫(kù)管理系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)是一個(gè)集合了中小型超市所有特點(diǎn)的一個(gè)管理系統(tǒng), 它使用當(dāng)下最流行的PHP語(yǔ)言來(lái)進(jìn)行開發(fā),實(shí)現(xiàn)了管理員登錄,員工登錄,超市內(nèi)物資基本信息管理,進(jìn)貨信息管理,銷售信息管理,超市內(nèi)員工信息管理,查詢統(tǒng)計(jì)等功能, 通過(guò)這些功能可以讓超市的

    2024年02月09日
    瀏覽(24)
  • PHP-MYSQL學(xué)生信息管理系統(tǒng)(附源碼免費(fèi))

    PHP-MYSQL學(xué)生信息管理系統(tǒng)(附源碼免費(fèi))

    本系統(tǒng)采用phpstudy開發(fā)平臺(tái),采用PHP和MySQL數(shù)據(jù)庫(kù)進(jìn)行開發(fā),開發(fā)工具為HBuilder。phpStudy是一個(gè)PHP調(diào)試環(huán)境的程序集成最新的 Apache+PHP+MySQL+phpMyAdmin,一次性安裝,無(wú)須配置即可使用,是非常方便、好用的PHP調(diào)試環(huán)境。(其他平臺(tái)均可) @@@文末有獲取方式免費(fèi)獲取 ———————

    2024年02月03日
    瀏覽(27)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包