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)文章
php代碼優(yōu)化及php相關(guān)問(wèn)題總結(jié)
php代碼優(yōu)化及php相關(guān)問(wèn)題總結(jié)...2006-10-10
親密接觸PHP之PHP語(yǔ)法學(xué)習(xí)筆記1
親密接觸PHP之PHP語(yǔ)法學(xué)習(xí)筆記1...2006-12-12
php與mysql建立連接并執(zhí)行SQL語(yǔ)句的代碼
進(jìn)入2011年的暑假,已經(jīng)要大三了,也該點(diǎn)更深刻的東西了。綜合各方面的因素,決定還是先學(xué)習(xí)學(xué)習(xí)php,等有所掌獲之后在去了解其他方面的東西。2011-07-07

