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

PHP数据库的操作

时间:2015-04-28 18:57:24      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:php   数据库   

<?php

$conn=mysql_connect("localhost","root","");

$result2=mysql_db_query("hello_world", "insert into hello_table values (‘add‘,8)",$conn);

$result=mysql_db_query("hello_world", "select * from hello_table",$conn);

$sss=mysql_fetch_object($result);

echo "+++++++++".$sss->age;//get the first value

$row=mysql_fetch_row($result);

for($i=0;$i<mysql_num_fields($result);$i++){

echo mysql_field_name($result, $i)." ";

}

echo "<br>";

mysql_data_seek($result, 0);

while($row=mysql_fetch_row($result)){

for($i=0;$i<mysql_num_fields($result);$i++){

echo $row[$i]." ";

}

echo "<br>";

}

mysql_free_result($result);

mysql_close($conn);

 

?>

PHP数据库的操作

标签:php   数据库   

原文地址:http://5618698.blog.51cto.com/5608698/1639729

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