PHP 存取 MySQL 數(shù)據(jù)庫(kù)的一個(gè)例子
更新時(shí)間:2006年10月09日 00:00:00 作者:
<body>
<center>
<h2>PHP+MySQL 例子</h2>
<h3><u><font color=brown>請(qǐng)?jiān)谖谋緟^(qū)域輸入數(shù)據(jù)并且確定 </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>
【本文版權(quán)歸作者與奧索網(wǎng)共同擁有,如需轉(zhuǎn)載,請(qǐng)注明作者及出處】
<center>
<h2>PHP+MySQL 例子</h2>
<h3><u><font color=brown>請(qǐng)?jiān)谖谋緟^(qū)域輸入數(shù)據(jù)并且確定 </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>
【本文版權(quán)歸作者與奧索網(wǎng)共同擁有,如需轉(zhuǎn)載,請(qǐng)注明作者及出處】
相關(guān)文章
一步一步學(xué)習(xí)PHP(8) php 數(shù)組
與其把PHP中的數(shù)組理解為我們狹義上的“數(shù)組”,我覺(jué)得還不妨把這個(gè)數(shù)組一分為二,一者為我們常規(guī)上的數(shù)組,一者為我們的Dictionary。2010-03-03PHP中call_user_func_array()函數(shù)的用法演示
今天,看了一段代碼,里面用到了很多call_user_func_array()函數(shù),一開(kāi)始,也是非常的迷糊,后來(lái)經(jīng)過(guò)查手冊(cè)發(fā)現(xiàn),call_user_func_array()函數(shù)還是很好用的,所以把PHP中call_user_func_array()函數(shù)用法用簡(jiǎn)單的代碼示例來(lái)說(shuō)明一下2012-02-02