
正文
php查询表单里的数据库 php查询表单里的数据库是什么
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
php怎样验证表单文本区域内容是否已存在数据库中?
方法php查询表单里的数据库:查询数据php查询表单里的数据库,若数据存在则输出(前端这个要自己写php查询表单里的数据库,我只写php查询表单里的数据库了一个echo)
代码如下:
//$conn = new mysqli($sql_server_name, $sql_username, $sql_password, $sql_db);
$timu = $_GET["timu"];
$sql = $conn-query("查询 * from problems where timu
='". $timu . "'"); // 从problems库里查 注意把“查询”改成“select”php查询表单里的数据库,因为百度知道会屏蔽sql语句
if (mysqli_fetch_assoc($sql) 0) {
echo "已存在";
} else {
echo "不存在";
}
相关问答
Q1: php如何查询数据库表中的数据并显示
这个简单啊!
首页做个前台输入姓名和会员卡信息的页面,我做个简单的页面给你看
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
html xmlns="
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
title会员查询系统/title
/head
body
form id="form1" name="form1" method="post" action="test.php"
p
label for="name"/label
input type="text" name="name" id="name" /
/p
p
label for="vipid"/label
input type="text" name="vipid" id="vipid" /
/p
p
input type="submit" name="button" id="button" value="查询" /
/p
/form
/body
/html
然后我给你一个test.php的文件代码:
?php
$name = trim($_POST['name']);
$vipid = trim($_POST['vipid']);
$con = mysql_connect("127.0.0.1","数据库用户名","数据库密码");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$a = mysql_select_db("数据库名字", $con);
$sql = "select * from kh_customer where name = '$name' and vipid = '$vipid'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo $row['name'] . " " . $row['data'];
echo "br /";
}
mysql_close($con);
?
页面美化自己去搞!只能帮你这么多了
Q2: 用PHP代码如何查询数据库表中的一条记录
你的意思是说
点击查询后
要吧与关键字相关联的整条记录都显示出来?
那样的话
你要先把这条记录复制
给某个数组,然后输出这个数组就可以了
$sql="select
*
from
db1
where
name=$_post[name]";
$result=mysql_query($sql,$con);
$row=mysql_fetch_array($result)
echo
$row[name];
echo
$row[age];
……
关于php查询表单里的数据库和php查询表单里的数据库是什么的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。








