标签:
1.
<?php
/* MySQL
create database foo charset gbk
create database foo charset utf8
*/
$conn = mysql_connect(‘localhost‘,‘root‘,‘‘);
if($conn){
//echo ‘connect success‘;
mysql_select_db(‘myapp‘,$conn);
// $result = mysql_query("SELECT id, name FROM users WHERE id = 1");
// $result_arr = mysql_fetch_assoc($result);
// print_r($result_arr);
// $result_arr = mysql_fetch_assoc($result);
// print_r($result_arr);
// echo ‘data length: ‘.mysql_num_rows($result);
// $data_count = mysql_num_rows($result);
// for($i=0;$i<$data_count;$i++){
// print_r(mysql_fetch_assoc($result));
// }
$result = mysql_query("SELECT COUNT(*) FROM users WHERE name = ‘iwen‘");
if($result){
$result_arr = mysql_fetch_array($result);
echo ‘data length: ‘.$result_arr[0];
}else{
echo ‘query fail‘;
}
}else{
echo ‘connect fail‘;
}
标签:
原文地址:http://www.cnblogs.com/htmlphp/p/4844058.html