PHP 存取 MySQL 数据库的一个例子
程序员文章站
2022-05-25 20:31:10
php+mysql 例子
<body>
<center>
<h2>php+mysql 例子</h2>
<h3><u><font color=brown>请在文本区域输入数据并且确定 </font></u></h3>
<form action="<? echo $php_self?>" method=post>
<textarea cols=40 rows=5 name=txt></textarea>
<br>
<input type="submit" value="确定">
</form>
<?
$connect_id=mysql_connect("localhost","username","password");
if(isset($txt)) {
$dbtime=date("y-m-d h:i:s");
mysql_db_query("usernamedb","insert into test values (0,'$dbtime','$txt')");
}
?>
<p>
</center>
<div align=center><center>
<table border=1 cellpadding=0 cellspacing=2 width=80%>
<tr><td>
<?
$result=mysql_db_query("usernamedb","select * from test");
while($userdb=mysql_fetch_row($result))
{
echo "<".$userdb[0].">: <font color=purple>".$userdb[1]."</font> <font color=red>".$userdb[2]."</font><br>n";
}
mysql_close($connect_id);
?>
</td></tr>
</table>
<p>
</body>
</html>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
上一篇:
ubuntu安装vbox虚拟机
下一篇:
MySQL临时表
<body>
<center>
<h2>php+mysql 例子</h2>
<h3><u><font color=brown>请在文本区域输入数据并且确定 </font></u></h3>
<form action="<? echo $php_self?>" method=post>
<textarea cols=40 rows=5 name=txt></textarea>
<br>
<input type="submit" value="确定">
</form>
<?
$connect_id=mysql_connect("localhost","username","password");
if(isset($txt)) {
$dbtime=date("y-m-d h:i:s");
mysql_db_query("usernamedb","insert into test values (0,'$dbtime','$txt')");
}
?>
<p>
</center>
<div align=center><center>
<table border=1 cellpadding=0 cellspacing=2 width=80%>
<tr><td>
<?
$result=mysql_db_query("usernamedb","select * from test");
while($userdb=mysql_fetch_row($result))
{
echo "<".$userdb[0].">: <font color=purple>".$userdb[1]."</font> <font color=red>".$userdb[2]."</font><br>n";
}
mysql_close($connect_id);
?>
</td></tr>
</table>
<p>
</body>
</html>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
<center>
<h2>php+mysql 例子</h2>
<h3><u><font color=brown>请在文本区域输入数据并且确定 </font></u></h3>
<form action="<? echo $php_self?>" method=post>
<textarea cols=40 rows=5 name=txt></textarea>
<br>
<input type="submit" value="确定">
</form>
<?
$connect_id=mysql_connect("localhost","username","password");
if(isset($txt)) {
$dbtime=date("y-m-d h:i:s");
mysql_db_query("usernamedb","insert into test values (0,'$dbtime','$txt')");
}
?>
<p>
</center>
<div align=center><center>
<table border=1 cellpadding=0 cellspacing=2 width=80%>
<tr><td>
<?
$result=mysql_db_query("usernamedb","select * from test");
while($userdb=mysql_fetch_row($result))
{
echo "<".$userdb[0].">: <font color=purple>".$userdb[1]."</font> <font color=red>".$userdb[2]."</font><br>n";
}
mysql_close($connect_id);
?>
</td></tr>
</table>
<p>
</body>
</html>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
上一篇: ubuntu安装vbox虚拟机
下一篇: MySQL临时表