这样接收post来的变量$_POST['变量名'];
这样接收get来的变理$_GET['变量名'];if($_POST['result'])
{
 echo "Found thes entries in the database:<br>";
 echo "<table width=90% align=center border=1><tr>
  <td>idx</td>
  <td>username</td>
  <td>last name</td>
  </tr>";
  while($r=mysql_fetch_array($result))
 {
   $idex=$r["idx"];
   $user=$r["username"];
   $last=$r["lastname"];
   
   echo "<tr>
   <td>$idx</td>
   <td>$user</td>
   <td>$last</td>
   </tr>";
 }
  echo "</table>";

else
{
 echo "No data";
}
?> 

解决方案 »

  1.   

    $db=mysql_connect("localhost","root") or die(mysql_error());
    mysql_select_db("example",$db) or die(mysql_error());
    $result = mysql_query("select * from tbl", $db) or die(mysql_error());看看有没报错?
      

  2.   

    $db=mysql_connect("localhost","root","");
    mysql_select_db("example") or die("error");
    $result = mysql_query("select * from tbl";另外在Phpmyadmin里面输入你的sql看看有结果没 
      

  3.   

    tb1 不能做表名吗?$result = mysql_query("select * from tbl", $db); 总出错,把表名换成userinfo,然后就通过了<html> 
    <head><title>Web Database Sample Index</title> 
    </head> 
    <body bgcolor=#ffffff> 
    <h2>Data from tbl</h2> 
    <?php
    $link=mysql_connect("localhost","root","");
    mysql_select_db("example",$link) or die ("bbbbb");
    $result = mysql_query("select * from userinfo", $link) or die("aaaa"); 
    //此处$result得到的值为什么老是falseif($result)
    {
     echo "Found thes entries in the database:<br>";
     echo "<table width=90% align=center border=1><tr>
      <td>idx</td>
      <td>username</td>
      <td>last name</td>
      </tr>";
      while($r=mysql_fetch_array($result))
     {
       $idex=$r["idx"];
       $user=$r["username"];
       $last=$r["lastname"];
       
       echo "<tr>
       <td>$idx</td>
       <td>$user</td>
       <td>$last</td>
       </tr>";
     }
      echo "</table>";

    else
    {
     echo "No data";
    }?> </body> 
    </html>