1,phpÁ¬½ÓÊý¾Ý¿a
<?php
$dbhost = 'localhost';
$dbuser = 'root'; //ÄaµÄmysqlÓû§Ãu
$dbpass = '123456'; //ÄaµÄmysqlÃÜÂe
$dbname = 'data'; //ÄaµÄmysql¿aÃu
//Á¬½Ó±¾µØÊý¾Ý¿a
$GLOBALS["conn"] = mysql_connect($dbhost,$dbuser,$dbpass);
//´o¿ªÊý¾Ý¿a
mysql_select_db($dbname,$GLOBALS["conn"]);
?>
2.php¶ÁÈ¡Êý¾Ý¿aÖÐ,ijһ×Ö¶ÎÖµ
<?php
//¶ÁÈ¡Ò»ÁÐÊý¾Ý
$sql="select * from ec_admin";
$result = mysql_query($sql,$GLOBALS["conn"]);
printf("Óû§Ãu: %s
\n", mysql_result($result,3,"UserName"));
printf("ÃÜÂe: %s
\n", mysql_result($result,3,"UserPass"));
?>
3,php²aÈeijһÌoÊý¾Ý
<?php
$sql="insert into ec_admin(UserName,UserPass) values('liugongxun2','jakemary2')";
$result=mysql_query($sql,$GLOBALS["conn"])or die(mysql_error());
?>
4,php whileÑ»*
<?php
$sql="select * from ec_admin";
$result = mysql_query($sql,$GLOBALS["conn"]);
while($myrow = mysql_fetch_row($result))
{
printf("Óû§Ãu%s %sÃÜÂe
",$myrow[1],$myrow[2]);
}
?>
5,php do whileÑ»*
<?php
$sql="select * from ec_admin";
$result = mysql_query($sql,$GLOBALS["conn"]);
if($myrow = mysql_fetch_array($result))
{
do
{
printf("Óû§Ãu%s %sÃÜÂe
",$myrow["UserName"],$myrow["UserPass"]);
}while($myrow = mysql_fetch_array($result));
}
?>
6,phpÅжϱiµ¥ÊÇ*ñÌa½»
<?php
if ($submit)
{}
?>