
正文
php查找数据库名 php7查询数据库
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
php 多条件查询数据库MySQL
SELECT * FROM `表名` WHERE bookid=22
获取BOOKID为22的记录,输出$uid=
if(strpos($uid,"2")!==false):echo"包含";else:echo"不包含";endif;
判断UID中是否含有2
MYSQLI方法统计数量
$num=mysqli_num_rows(mysqli_query($mysqli,"SELECT id FROM `表名` where pinglun=1"));
统计该表中pinglun=1的记录数量
相关问答
Q1: php5以上版本,怎样查找数据库中表名,以及表名中有哪些字段名?
mysql_list_tables 在php5应该支持的,再说,向下兼容的啊帮助文档:例 1397. mysql_list_tables() 例子/b?php
$dbname = 'mysql_dbname';
if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
print 'Could not connect to mysql';
exit;
}
$result = mysql_list_tables($dbname);
if (!$result) {
print "DB Error, could not list tables\n";
print 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result)) {
print "Table: $row[0]\n";
}
mysql_free_result($result);
?
Q2: php搜索查询数据库
1.action 后面的页面没有指定
2.if($name) 改成 if($name!=‘’)
3.把$sql 打印出来
4.页面报错内容是什么
完善上面4项,纠错毫无压力。
Q3: PHP+MYSQL 怎样按条件查询数据库里表的名称?
mysql
有一个默认的数据库,叫做information_schema
连上这个库,执行下面的语句(你自己那可能的改下下面的sql)
//table_schema
是你的数据库名字
table_name是表名
select
*
from
tables
where
table_schema
=
'storage'
and
table_name
like
'product%'
你看看库中这个表结构就明白了,呵呵
Q4: 如何实现PHP查询数据库,信息匹配成功,跳转页面?
?php
$localhost = 'localhost';//本地的基本是用localhost
$dbname = 'dbname';//数据库名
$user = 'user';//用户名
$pw = 'pw';//密码
$pdo = new PDO("mysql:host=".$localhost.";dbname=".$dbname."",$user,$pw);
$pdo-query('set names utf8');
$username = $_POST['username'];
$userpassword = $_POST['userpassword'];
$sql = 'SELECT userpassword FROM `userinf` WHERE `username`="' . $username . '"';
$row = $pdo-query($sql)-fetch();//查询数据库
if($userpassword == $row['userpassword'])
{
@header("Location: http://网址");//配对成功,跳转
}
else
{
exit('不好意思,你的密码不对');
}
/*
就是这么的简单,但是一般的验证用户密码不是这样的,首先一般存数据库里面的密码都是加密的,通常的MD5加密
而且POST提交过来的数据也要过滤一下
*/
?
!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 method="POST"
用户名:input name="username" type="text" / | 密码:input name="userpassword" type="password" / | input type="submit" value="提交"
/form
/body
/html
Q5: 哪位大哥帮帮忙 php 中如何获取当前执行的sql 所在的数据库名称 谢了
执行sql语句所在的数据库不是写着吗?
例如:
如果你上次执行的sql语句是:
select * from pro.test;
pro就是数据库名字。
test就是表名。
php查找数据库名的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于php7查询数据库、php查找数据库名的信息别忘了在本站进行查找喔。






