码迷,mamicode.com
首页 > 数据库 > 详细

php数据库连接和mysql语句使用

时间:2014-11-01 17:44:36      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   使用   sp   数据   div   on   

从简单的登录页开始学习。

前提:已经有一个html+css+js的静态网站

登录:

  php连接数据库,读取数据。

 1 <?php
 2 $username = root;
 3 $userpass = shao;
 4 $dbhost = localhost;
 5 $dbdatabase = mytest;
 6 
 7 //首先生成一个连接
 8 $db_connect = mysql_connect("localhost", "root", "shao") or die("Unable to connect to the MySQL!");
 9 
10 //选择一个操作的数据库
11 mysql_select_db("mytest", $db_connect);
12 
13 //执行增删改查语句
14 mysql_query("select * from user");
15 
16 ?>

 

php数据库连接和mysql语句使用

标签:style   blog   color   os   使用   sp   数据   div   on   

原文地址:http://www.cnblogs.com/blog-of-Fourier/p/4067402.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!