1,PHP连接数据库 <?PHP $dbhost='localhost';
$dbuser='root';//你的MysqL用户名
$dbpass='123456';//你的MysqL密码
$dbname='data';//你的MysqL库名 //连接本地数据库
$GLOBALS["conn"]=MysqL_connect($dbhost,$dbuser,$dbpass); //打开数据库
MysqL_select_db($dbname,$GLOBALS["conn"]); ?> 2.PHP读取数据库中,某一字段值 <?PHP //读取一列数据
$sql="selectfromec_admin";
$result=MysqL_query($sql,$GLOBALS["conn"]); printf("用户名:%s
\n",MysqL_result($result,3,"UserName"));
printf("密码:%s
\n","UserPass")); ?> 3,PHP插入某一条数据 <?PHP $sql="insertintoec_admin(UserName,UserPass)values('liugongxun2','jakemary2')";
$result=MysqL_query($sql,$GLOBALS["conn"])ordie(MysqL_error()); ?> 4,PHP while循环 <?PHP $sql="selectfromec_admin";
$result=MysqL_query($sql,$GLOBALS["conn"]);
while($myrow=MysqL_fetch_row($result))
{
printf("用户名%s%s密码
",$myrow[1],$myrow[2]);
} ?> 5,PHP dowhile循环 <?PHP $sql="select*fromec_admin";
$result=MysqL_query($sql,$GLOBALS["conn"]);
if($myrow=MysqL_fetch_array($result))
{
do
{
printf("用户名%s%s密码
",$myrow["UserName"],$myrow["UserPass"]);
}while($myrow=MysqL_fetch_array($result));
}
?> 6,PHP判断表单是否提交 <?php if($submit) {} ?>