<?php
echo "<head>";
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>";
echo "<title>无标题文档</title>";
echo "</head>";
require("myfun2.php");
$connect_id=mysql_connect('localhost','root','');
mysql_select_db('gcjd');
mysql_query("set names utf8");
$sql1="SELECT DISTINCT jh FROM gcjdrb";
$res1=mysql_query($sql1,$connect_id);
//echo "这是".$row[0]."<br/>";
//var_dump($row);//此处可以看出这个数据的全部结构
$rows=mysql_affected_rows($connect_id);//获取sql语句受影响的行数
$colums=mysql_num_fields($res1);//获取受影响的列数
echo "<table width='300' border='1' height='200'>";
/* for($i=0;$i<$colums;$i++){//此句打印出表头
$field_name=mysql_field_name($res1,$i);
echo "<th>$field_name</th>";
} */
for($i=0;$i<$rows;$i++){
while($row=mysql_fetch_row($res1)){//$row=mysql_fetch_row($res1)将查询结果斌给变量$row数组
echo "<tr>";
echo "<td>$row[$i]</td>";
echo "</tr>";
}
}
echo "</table>";
mysql_free_result($res1);
mysql_close($connect_id);
?>
获取sql语句影响的数据条数并打印到表格
最新推荐文章于 2017-08-30 11:32:41 发布