All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
用VS2005实现ASP.NET2.0移动开发_[Asp.Net教程]
AJAX技术在PHP开发中的简单应用_php资料_编程技术
建立灵巧结构的PHP程序_php资料_编程技术
Windows,IIS环境下安装和配置PHP开发环境_php资料_编程技术
三个SQL视图查出所有SQL Server数据库字典_[SQL Server教程]
在asp.net2.0页面部分缓存中使用@ OutputCache指令
初学,ASP.NET,AJAX,(四):Timer,和,UpdateProgress_[Asp.Net教程]
delphi向一个文件中添加内容
鼠标移过Div层显示层中信息由数据库中提出_[Asp.Net教程]
用一句SQL取出第m条到第n条记录的方法_[SQL Server教程]
Reading number is top 10 pictures
The real super beauty12
China telecom 114 spokesman MeiYanXu2
Chinese paper-cut grilles art appreciation5
各种囧况!玩游戏最不喜欢出现的十件事(点评)
接财神,大吉大利,财源滚滚来
2012 national geographic daily picture3
Absolutely shocked. National geographic 50 animal photographys8
世界五大海盗
小学生考试又现神作--还有外国的
Perfect small Laurie1
Download software ranking
I'm come from Beijing1
jBuilder2006
jdk1.6 for windows
Unix video tutorial14
The Bermuda triangle1
Love the forty days
Boxer Classic video3
中国结婚习俗实录
Unix video tutorial5
塘西风月痕
aaa published in(发表于) 2013/12/21 22:35:37 Edit(编辑)
入门:PHP与MYSQL的结合操作_php资料_编程技术

入门:PHP与MYSQL的结合操作_php资料_编程技术

入门:PHP与MYSQL的结合操作_php资料_编程技术-你的首页-uuhomepage.com

1,连接数据库

$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.读取数据库中,某一字段值

//读取一列数据
$sql="select * from ec_admin";
$result = mysql_query($sql,$GLOBALS["conn"]);

printf("用户名: %s
\n", mysql_result($result,3,"UserName"));
printf("密码: %s
\n", mysql_result($result,3,"UserPass"));

?>

3,插入某一条数据

$sql="insert into ec_admin(UserName,UserPass) values('liugongxun2','jakemary2')";
$result=mysql_query($sql,$GLOBALS["conn"])or die(mysql_error());

?>

4,while循环

$sql="select * from ec_admin";
$result = mysql_query($sql,$GLOBALS["conn"]);
while($myrow = mysql_fetch_row($result))
{
printf("用户名%s %s密码
",$myrow[1],$myrow[2]);
}

?>

5,do while循环

$sql="select * from ec_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,判断表单是否提交

if ($submit)

{}

?>




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.