PHP调用三种数据库的方法(1)(2)

2008-02-23 06:30:38来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折



$num_fields = mysql_num_fields($rst);//取得字段总数

$i = 0;

while($i<$num_fields){//取得所有字段的名字

$fields[$i] = mysql_field_name($rst,$i);//取得第i 1个字段的名字

$i ;

}

echo "<table border="1" cellspacing="0" cellpadding="0">";//开始输出表格

echo "<tr>";

reset($fields);

while(list(,$field_name)=each($fields)){//显示字段名称

echo "<th>$field_name</th>";

}

echo "</tr>";

while($row=mysql_fetch_array($rst)){//显示本页数据

echo "<tr>";

reset($fields);

while(list(,$field_name)=each($fields)){//显示每个字段的值

$field_value = $row[$field_name];

if($field_value==""){

echo "<td> </td>";

}

else{

echo "<td>$field_value</td>";

}

}

echo "</tr>";

}

echo "</table>";//表格输出结束

mysql_free_result($rst) or die("无法释放result资源!");//释放result资源

}

else{

echo "目前该表中没有任何数据!";

}

mysql_close($server) or die("无法与服务器断开连接!");//断开连接并释放资源

?>

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:PhpMyAdmin中无法导入sql文件的解决办法

下一篇:php的计数器程序