资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

网页显示数据库表单php,显示数据库列表

如何用php页面提交表单到数据库

1:首先要使用PHP的超全局变量 $_GET 和 $_POST 用于收集表单数据(form-data) 2:然后使用INSERT INTO 语句用于向数据库表中插入新记录。 具体示例: (1)首先创建了一个名为 "Persons" 的表,有三个列:"Firstname", "Lastname" 以及 "Age"。

莲花网站建设公司成都创新互联,莲花网站设计制作,有大型网站制作公司丰富经验。已为莲花数千家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的莲花做网站的公司定做!

怎么把MySQL数据库表的内容,通过数据表中的数据检索为条件,以表单的形式,显示在PHP页面。

编写调试代码,回答有点晚了,以下是一个比较完整的示例:

下面输出一个表格,两个输入框,输入用户号和密码:

form id="form1" name="form1" method="post" action="chaxun.php"

table width="344" height="136" border="0" align="center" cellpadding="2" cellspacing="2"

td width="100" height="35" align="right"用户号:/td

td width="275"input type="text" name="online_number" id="online_number" width="150" //td

/tr

tr

td align="right"密码:/td

td height="35"input type="password" name="online_pass" id="online_pass" width="150" //td

/tr

tr

td height="45" colspan="2" align="center"input type="submit" value="注册" / /td

/tr

/table

/form

?php

//下面编写处理代码,有说明

header('Content-type:text/html;charset=utf-8');//设置编码格式为utf8

if(isset($_POST['online_number']) isset($_POST['online_pass']))

{

$db = new mysqli('localhost','test','test','db_online');//建立数据库连接,用户名、密码、数据库根据实际修改

$pass = $_POST['online_pass'];

$num = $_POST['online_number'];

$rows = $db-query("SELECT * FROM tb_user WHERE online_number = $num AND online_pass ='$pass'");

$r_num = $rows-num_rows;

if($r_num0)

{

echo 'table border="1"tr';

$row = $rows-fetch_row();

for($i=0;$icount($row);$i++)

{

echo 'td'.$row[$i].'/td';

}

echo '/tr';

} else

echo 'scriptalert("用户号或密码错误");/script';

}

?

将以上代码保存为chaxun.php,修改你实际的数据库连接 用户名和密码,运行

请问怎么用php做网页一打开,就连接数据库并读取表打印在网页表单

这个简单,首先你得先要链接好数据库,其次就是查询数据库,就2步。

至于查看,删除的就更简单了,带上id号就行了

?php 

mysql_connect("localhost","你的数据库用户名","你的数据库密码");

mysql_select_db("你的数据库");

$sql=mysql_query("select * from 数据表");

?

table width="100%" border="0"

tr

tdID/td

td名称/td

td操作/td

/tr

?php while($row=mysql_fetch_array($sql)){?

tr

td?php echo $row['字段名']?/td

td?php echo $row['字段名']?/td

tda href="?id=?php echo $row['id字段']?"查看/a/td

/tr

?php }?

/table


网站题目:网页显示数据库表单php,显示数据库列表
URL网址:http://cdkjz.cn/article/hshhgi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220