| PHP不同查尋介面範例<?php include "config.php"; $command=$_POST["command"]; if ($command==null) { echo(" <html> <title>PHP 不同介面查詢範例</title> <center> <form method='post' action=$PHP_SELF> <table border=0> <tr> <td>學號:</td> <td> <input type='text' name='student_no' size='9'> </td> </tr> </table> <input type='submit' name='command' value='新增'> <input type='submit' name='command' value='查詢'> <input type='reset' name='command' value='清除 '> </form> </center> </html> "); } if ($command=="查詢") { $student_no=$_POST["student_no"]; if ($student_no==null || $student_no=="") $student_no="%"; $sql="select * from stmd where student_no like '$student_no' order by student_no"; $result=mysql_query($sql,$conn); echo("<html> <body> <center> <form method='post' action='$SELF_PHP'> <table border=1> <tr><td>選擇</td><td>學號</td></tr> "); while ($myrow=mysql_fetch_array($result)) { $student_no=$myrow["student_no"]; echo "<tr><td>"; echo "<input type=radio name=student_no value='$student_no'>"; echo "</td><td>"; echo $student_no; echo "</td></tr><br>"; } echo "</table>"; echo "<input type='submit' name='command' value='更新'> <input type='submit' name='command' value='刪除'> <input type='reset' name='command' value='清除 '> </form> </center> </body> </html> "; } if ($command=="更新") { $student_no=$_POST["student_no"]; echo $student_no; } ?> | |