php keywords select

來源:互聯網
上載者:User

標籤:else   form   演講   mon   btn   ima   empty   while   row   

視圖:

<form action="select_like.php" method="post">
<table class="search-tab">
<tr>
<th width="120">選擇分類:</th>
<td>
<select name="search-sort" id="">
<option value="">全部</option>
<option value="19">運動健身</option>
<option value="20">旅遊</option>
<option value="21">文學藝術</option>
<option value="22">演講</option>
<option value="23">經濟</option>
<option value="24">電影</option>
<option value="25">科技</option>
<option value="26">美食</option>
</select>
</td>
<th width="70">關鍵字:</th>
<td><input class="common-text" placeholder="關鍵字" name="keywords" value="" id="" type="text"></td>
<td><input class="btn btn-primary btn2" name="sub" value="查詢" type="submit"></td>
</tr>
</table>
</form>

控制器:

<?php
// var_dump($_POST);
$con = mysql_connect("localhost",‘root‘,‘12‘);
mysql_select_db(‘news‘,$con);
mysql_query(‘set names utf8‘);
$arrAll = array();
if (!empty($_POST[‘keywords‘])) {
$keywords = $_POST[‘keywords‘];
// echo "select * from newsup where `title` like ‘%{$keywords}%‘";
$result = mysql_query("select * from newsup where `title` like ‘%{$keywords}%‘") or die(‘select fail‘);
while ($row = mysql_fetch_assoc($result)) {
$arrAll[] = $row;
}
}else{

$result = mysql_query("select * from newsup") or die(‘select fail‘);
while ($row = mysql_fetch_assoc($result)) {
$arrAll[] = $row;
}
}
?>

php keywords select

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.