‘;
echo ‘‘;
// 显示字段名称
echo "";
for($i = 0; $i < mysql_num_fields ( $result ); $i ++) {
echo ‘‘ . mysql_field_name ( $result, $i );
echo " | ";
}
echo "
";
// 定位到第一条记录
mysql_data_seek ( $result, 0 );
// 循环取出记录
while ( $row = mysql_fetch_row ( $result ) ) {
echo "";
for($i = 0; $i < mysql_num_fields ( $result ); $i ++) {
echo ‘‘;
echo $row [$i];
echo ‘ | ‘;
}
echo "
";
}
echo "
";
echo "";
/*
* $sql = "insert into tb_sql(sname, spassword, bumen) values(‘zhangsan‘, ‘123456‘, ‘外联部‘)"; mysql_query($sql); //执行插入语句 echo "插入成功!" ;
*/
// 释放资源
mysql_free_result ( $result );
// 关闭连接
mysql_close ( $conn );
?>php连接mysql数据库(查询,插入数据)
原文:http://www.cnblogs.com/wwxblog/p/4277564.html