php如何从获取数据 php怎么获取数据库中的数据( 二 )


}
$mysqli = new mysqli("localhost", "test", "test", "room");
if ($mysqli-connect_error) {
printf("数据库连接错误: %s\n", mysqli_connect_error());
exit();
}
?
table border="1" cellspacing="0"
tr
td bgcolor="?php echo getColor($mysqli,'1')?"1/td
/tr
tr
td bgcolor="?php echo getColor($mysqli,'2')?"2/td
/tr
tr
td bgcolor="?php echo getColor($mysqli,'3')?"3/td
/tr
/table
?php
$mysqli-close();
?
php怎么从表单接收数据PHP 可以通过POST、GET方法获取到表单提交的数据
获取到的POST、GET是数组形式的值,需要通过键值来详细获取相应的值
比如: index.php 页面
下面是POST方法
form name="form1" method="post" action="index.php"
input type="text" name="contents" value=""
input type="submit" value="https://www.04ip.com/post/提交"
/form
?php
//获取表单提交的数据
$contents = $_POST['contents'];
echo $contents;
?
也可以是下面是GET方法
form name="form1" method="get" action="index.php"
input type="text" name="contents" value=""
input type="submit" value="https://www.04ip.com/post/提交"
/form
?php
//获取表单提交的数据
$contents = $_GET['contents'];
echo $contents;
?
POST相对于GET方法,更好一些,可以提交大量数据,以及更安全些 。
php如何获取数据库信息代码如下:?View
Code
PHP
include("conn.php");//调用数据库连接文件
echo
"table
width=572
height=56
cellspacing=1
";
//创建html表格
echo
"tr
bgcolor=#9999FF";
echo
"th
width=33
scope=colid/th";
echo
"th
width=100
scope=coluser_name/th
";
echo
"th
width=100
scope=coluser_pass/th
";
echo
"th
width=100
scope=colstaus/th";
echo
"th
width=100
scope=colinsert_time/th";
echo
"/tr";
$SQL
=
"select
*
from
user_info";
$query
=
mysql_query($SQL);
//SQL查询语句
while
($row
=
mysql_fetch_array($query)){
//使用while循环mysql_fetch_array()并将数据返回数组
echo
"tr
onmouseout=this.style.backgroundColor=''
onMouseOver=this.style.backgroundColor='#99CC33'
bgcolor=#CCCCCC";
echo
"td$row[0]/td";
//输出数组中数据
echo
"td$row[1]/td";
echo
"td$row[2]/td";
echo
"td$row[3]/td";
echo
"td$row[4]/td";
echo
"/tr";
}
echo
"/table";输出记录截图
【php如何从获取数据 php怎么获取数据库中的数据】关于php如何从获取数据和php怎么获取数据库中的数据的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读