<html><head><title>测试</title><meta http-equiv="content-type" content="text/html;charset=gb2312" /></head><body><form action="" method="post"><table><tr><td>表名</td><td><input type="text" name="tablename"/></td></tr><tr><td colspan="2"><input type="submit" name="submit" value="提交"></td></tr></table></form></body></html><?php $link = mysql_connect('localhost','root','') or die('Could not connect to MySQL'); mysql_select_db('test2',$link) or die('数据库连接错误'); if(isset($_POST['submit']) && $_POST['submit'] == '提交') { $tablename = isset($_POST['tablename']) ? $_POST['tablename'] : ''; if(!$tablename) exit('请输入表名'); $sql = "select count(*) as num from $tablename"; $rows = mysql_query($sql); $row = mysql_fetch_row($rows); echo '表 '.$tablename.' 共有 '.$row[0].' 条数据'; }else{ echo 'error'; }