PHP Mysql查询
来源:互联网 发布:php构造函数的作用 编辑:程序博客网 时间:2024/05/17 02:43
ZendStudio: Alt + right / Alt + left // skip to the last edit place
$_POST // read occurence of $_POST PHP $_POST and $_GET method to send data to
PHP is not strong-typeing ,so there is no need to definite return type when generate a method
is_numeric -- 检测变量是否为数字或数字字符串
parent::__construct ( $host, $user, $pwd, $dbname ); // call the constructor of parent. equal to DataBase ::_construct
$sql = "select wealth from user where uid= +$uid"; // '+' 连接查询字符串
mysql_fetch_array -- 从结果集中取得一行作为关联数组,或数字数组,或二者兼有
如果用了 MYSQL_BOTH,将得到一个同时包含关联和数字索引的数组。用 MYSQL_ASSOC 只得到关联索引(如同 mysql_fetch_assoc() 那样),用 MYSQL_NUM 只得到数字索引(如同 mysql_fetch_row() 那样)。
注: 该函数返回的字段名是大小写敏感的。
2. mysql_fetch_array 使用 MYSQL_NUM
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf ("ID: %s Name: %s", $row[0], $row[1]);
}
mysql_free_result($result);
?>
例子 3. mysql_fetch_array 使用 MYSQL_ASSOC
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf ("ID: %s Name: %s", $row["id"], $row["name"]);
}
mysql_free_result($result);
?>
$_POST // read occurence of $_POST PHP $_POST and $_GET method to send data to
PHP is not strong-typeing ,so there is no need to definite return type when generate a method
is_numeric -- 检测变量是否为数字或数字字符串
parent::__construct ( $host, $user, $pwd, $dbname ); // call the constructor of parent. equal to DataBase ::_construct
$sql = "select wealth from user where uid= +$uid"; // '+' 连接查询字符串
mysql_fetch_array -- 从结果集中取得一行作为关联数组,或数字数组,或二者兼有
如果用了 MYSQL_BOTH,将得到一个同时包含关联和数字索引的数组。用 MYSQL_ASSOC 只得到关联索引(如同 mysql_fetch_assoc() 那样),用 MYSQL_NUM 只得到数字索引(如同 mysql_fetch_row() 那样)。
注: 该函数返回的字段名是大小写敏感的。
2. mysql_fetch_array 使用 MYSQL_NUM
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf ("ID: %s Name: %s", $row[0], $row[1]);
}
mysql_free_result($result);
?>
例子 3. mysql_fetch_array 使用 MYSQL_ASSOC
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf ("ID: %s Name: %s", $row["id"], $row["name"]);
}
mysql_free_result($result);
?>
- php查询MySQL数据
- PHP Mysql查询
- Php实现mysql查询
- PHP并行查询MySQL
- PHP/MYSQL查询一段时间记录
- PHP+MYSQL数据库查询显示
- php连接、查询mysql数据库
- php读取mysql分页查询
- php读取mysql分页查询
- php mysql PDO 查询操作
- php查询mysql乱码解决方案
- php查询mysql分页查询返回数组
- php+mysql,php连接mysql,查询与分页显示
- mysql查询错误原因+PHP复选框
- php查询mysql总结和预处理
- 【原创】PHP访问MySQL查询超时处理
- PHP访问MySQL查询超时处理
- PHP和MYSQL查询和分页显示
- 今日体会之JTabbedPane的使用和JFrame的透明化方法
- ASIHTTPRequest类库简介和使用说明
- Java基础知识——HashSet_TreeSet_Comparator
- 智能小车——摄像头
- jquery的extend和fn.extend
- PHP Mysql查询
- 网关串口+EM310
- VS2010串口通讯架构设计初探
- feedbacks from ICB2013
- OSX: 10.9 Mavericks的重要更新技术细节(1)
- 黑马程序员---类加载器
- asp.net后台cs中的JSON格式变量在前台Js中调用方法!(前后台实例!)
- 面向对象一(类、对象、变量、构造函数、构造代码块、this、static)
- 黑马程序员-JAVA基础加强-枚举