当前位置

首页 > 综合知识 > 搜索的代码怎么写

搜索的代码怎么写

推荐人: 来源: 秒知社 阅读: 5.57K 次
1. PHP的搜索的代码是怎样写的

<?php

搜索的代码怎么写

$conn=mysql_connect('localhost','数据库用户名','数据库密码');//连接数据库

mysql_select_db("chanping",$conn);//数据库名

$sql="select * from CP where BH=100";//查询语句

$ret=mysql_query($sql,$conn);//操作数据库

while($row=mysql_fetch_array($ret)){//遍历数组

echo $row['BH'];//输出

}

?>

2. asp.net中站内搜索的代码怎么写

搜索按钮代码 if (TextBox1.Text != "") { string search = TextBox1.Text; Response.Redirect("Default7.aspx?keyword=" + search); } else { Response.Write("<script>alert('请输入关键字!');</script>"); }接收页代码 public void Bind() { string keyword = Request.QueryString["keyword"].ToString(); SqlConnection con = new SqlConnection(conn); con.Open(); if (keyword != "") { Label1.Visible = false; SqlCommand cmd = new SqlCommand("select*from BookInf where Bookname like '%" + keyword + "%'", con); SqlDataAdapter dap = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); dap.Fill(ds); if (ds.Tables[0].Rows.Count == 0) { Label1.Text = "没有找到您要找的图书,请重新输入关键字!"; Label1.Visible = true; } else { DataList1.DataSource = ds; DataList1.DataBind(); } } else { Label1.Text = "请输入关键字!"; Label1.Visible = true; }。

3. 这个效果的HTML代码怎么写