<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>交互测试页</title>
</head>
<body>
<form method="POST" action="show.php">
<p><input type="submit" value="show" name="B3"></p>
</form>
<?php 
 if (count($_POST) > 0)
{
$link = mysql_pconnect("localhost", "root", "3033")
       or die("Could not connect: " . mysql_error());
mysql_select_db('123') or die ('can not select dtb');
$query='select * from ben';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
echo"<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
{
   echo "\t<tr>\n";
   foreach ($line as $col_value) {
       echo "\t\t<td>$col_value</td>\n";
   }
   echo "\t</tr>\n";
}
echo "</table>\n";
?></body>
</html>
 不知道可行不?改用SMARTY模版是最好的.

解决方案 »

  1.   

    啊....我这样问一下...我有一定编程基础的,但是没做过网在学呢.
    <form method="POST" action="show.php">
    <p><input type="submit" value="show" name="B3"></p>
    显然 action="show.php" 是说如果 被按了 激发 这个action="show.php" 
    那么如果我不是想打开 这个 网页,我想做些什么.
    就是 说我想在 action="show.php">的这个地方添加代码 应该怎么弄呀?
      

  2.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>交互测试页</title>
    </head>
    <body>
    <form method="POST" action="show.php">
    <p><input type="submit" value="show" name="B3"></p>
    </form><?php
    if($_SERVER['REQUEST_METHOD'] == "POST"):
    $link = mysql_pconnect("localhost", "root", "3033")
           or die("Could not connect: " . mysql_error());
    mysql_select_db('123') or die ('can not select dtb');
    $query='select * from ben';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    echo"<table>\n";
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
    {
       echo "\t<tr>\n";
       foreach ($line as $col_value) {
           echo "\t\t<td>$col_value</td>\n";
       }
       echo "\t</tr>\n";
    }
    echo "</table>\n";
    endif;
    ?>
    </body>
    </html> 
      

  3.   

    从编程角度说 当" 按键被按下时"做"打开show.php"
    我想改成 当" 按键被按下时"运行我添加的代码,这个在具体格式上怎么写呀?
      

  4.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>交互测试页</title>
    </head>
    <body>
    <form method="POST" action=<?php $_SERVER['PHP_SELF'] ?> >
    <p><input type="submit" value="show" name="B3" onClick="javascript:document.getElementById('button_name').value = "show" >
     <input type="hidden" name="button_name" id="button_name" /></p>
    </form>
    <?php 
     if (count($_POST) > 0)
    {
    $link = mysql_pconnect("localhost", "root", "3033")
           or die("Could not connect: " . mysql_error());
    mysql_select_db('123') or die ('can not select dtb');
    $query='select * from ben';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    echo"<table>\n";
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
    {
       echo "\t<tr>\n";
       foreach ($line as $col_value) {
           echo "\t\t<td>$col_value</td>\n";
       }
       echo "\t</tr>\n";
    }
    echo "</table>\n";
    ?></body>
    </html>
    麻烦你再看下,我改了点东西.早上比较闲,现在有点忙,加我MSN吧.CSDN名@hotmail.com
      

  5.   

    MSN   的地址 ...再写一遍吧没加明白..
    下班了...明天再研究了。..