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="select * from ec_admin";
$result = mysql_query($sql,$GLOBALS["conn"]);
printf("用户名: %s<br>\n", mysql_result($result,3,"UserName"));
printf("密码: %s<br>\n", mysql_result($result,3,"UserPass"));
?>
相关文档:
代码如下:
<?php
class Book{
static $num=0;
public function showme(){
echo '您是第'.self::$num.'位访客';
self::$num++;
......
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The follo ......
在PHP里,如果你没有手写构造函数,则php在实例化这个对象的时候,会自动为类成员以及类方法进行初始化,分配内存等工作,但是有些时候不能满足我们的要求,比如我们要在对象实例化的时候传递参数,那么就需要手动编写构造函数了,手写构造函数有两种写法,只是表现形式不同,其实本质一样
class test
{
&nb ......
在使用php中使用数据库事务处理并不复杂,主要用到的是mysqli类的3个成员函数。
(1)autocommit(bool mode),设置数据库自动提交状态。当mode为TRUE时,打开自动提交设置,当mode为FASLE时,关闭自动设置。所谓自动提交,就是MYSQL每执行一条SQL语句,该SQL语句的执行结果马上生效。而非自动提交时,则执行结果要一直到 ......
just get a json
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<mce:script src="jquery-1.3.2.min.js" mce_src="jq ......