对数据库进行编码转换。要用到一个功能,读出一个表,查询所有字段与所有数据,并判断字段值是数值型,还是字符型。
这样功能要怎么写呢。现在我的写法是这样的:[php]$sql="select * from ".$dbNameUTF8.$tableName;
$rsUTF=mysql_query($sql);
if (mysql_num_rows($rsUTF)==0) {
echo "<div>没有数据</div>";
}
else {
echo "<div>有数据</div>";
echo '<table border="1" cellpadding="0" cellspacing="0" width="100%" height="" align="center">';
$i=0;
while($rows=mysql_fetch_array($rsUTF))
{
  $sql="insert into ".$tableName." (classid, zz_title, z_title, qz_title, save_title, zz_titlepic, z_titlepic, qz_titlepic, save_titlepic, zz_newstime, z_newstime, qz_newstime, save_newstime, zz_ftitle) values (".$rows[classid].", '".$rows[zz_title]."', '".$rows[z_title]."', '".$rows[qz_title]."', '".$rows[save_title]."', '".$rows[zz_titlepic]."', ".$rows[z_titlepic].", '".$rows[qz_titlepic]."', '".$rows[save_titlepic]."', ".$rows[zz_newstime].", '".$rows[z_newstime]."', '".$rows[qz_newstime]."', '".$rows[save_newstime]."', '".$rows[zz_ftitle].')";
  echo "<div style='border:1px solid;font-size:11px;font-family:verdana;margin:5px;padding:5px;'>";
  echo $sql;
  echo "</div>";
  $i++;
}
echo "</table>";
}[/php]这样写的话,表不一样的话,字段改起来就很麻烦咯。望高手指点。就像ASP中直接循环记录集一样的方法:
[php]for j=0 to rs.Fields.count-1
       rsValue=rs.Fields(j).Value
       response.write(rsValue)
      next[/php]