Hi,Aaron,
thank u for your help,but it is not a problem on table name,every thing is OK(I did a lot experiment),I want to input a sql statement from a form,and let the PHP do the query and generate the data listing.I input some sql like inserting and alter table,all works well.but when I select something,the fieldnum is allways 1,and when I want to repeat by:
for ($i=0;$i<$rownum;$i++),it give nothing.
can u give me more suggestion?.
the code is following:
the fields name heading is fine.but only a heading,now data below.
{
$rs=mysql_query($sql,$conn);
echo $sql." OK !!<hr color=red>";
$rownum=mysql_num_rows($rs);
$fieldnum=mysql_num_fields($rs);
echo "fields num is ".$fieldnum;
echo "<br>row nums is:".$rownum;
echo "<table cellspacing=0 border=1 bordercolor=blue><tr>";
for($i=0;$i<=($fieldnum-1);$i++)
{echo "<td>".mysql_field_name($rs,$i)."</td>";}
echo "</tr>";
$i=0;
while ($i<$rownum)
{echo "<tr>";
for ($j=0;$j<=($fieldnum-1);$j++)
{ echo "<td>";
$fieldname=mysql_field_name($rs,$j);
echo mysql_result($rs,$i,$fieldname);
echo "</td>";
}
echo "</tr>";
$i++;
}
echo "</table>";
}
Barry Lee.
Lijiang,China