- 论坛徽章:
- 1
|
主页
- #score.htm
- <html><head>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=big5">
- <title>查询成绩</title>
- <form method="POST" action="Quary.php">
- <li>帐号:
- <input type="text" name="id" size="17" maxlength="32">
- </li>
- <li>密码:
- <input name="passwd" type="password" size="17" maxlength="32">
- </li>
- <li>登入:
- <input type="submit" value="Login" name="submit" id="btn">
- </li>
- </form>
- </body>
- </html>
复制代码
- #Quary.php
- <html>
- <BODY>
- <form method="POST" action="Quary.php">
- <select name="select" size="1" type="text">
- <option value="1">国文</option>
- <option value="2">英文</option>
- <option value="3">数学</option>
- <option value="4">全部</option>
- </select>
- <input type="submit" value="确定" name="OK">
- </form>
- </BODY>
- </html>
- <?php
- function my_score($Quary_id,$pw)
- {
- if ( !strcmp("root",$Quary_id) && !strcmp("1234",$pw) )
- {
- $link = @mysql_connect("localhost", $Quary_id, $pw) or die("糟糕!无法连上资料库喔!" . mysql_error());
- echo "恭喜资料库已经连上啰!"."<BR>";
- mysql_select_db("score");
- $result=mysql_query("select * from total");
- while($data=mysql_fetch_array($result))
- {
- echo "国文".$data[0]."<BR>";
- echo "英文".$data[1]."<BR>";
- echo "数学".$data[2]."<BR>";
- $total = $data[0] + $data[1] + $data[2];
- echo "总分".$total."<BR>";
- echo "平均".($total / 3)."<BR>";
- }
- mysql_close($link);
- }
- else
- {
- echo "密码错误或是帐号错误"."<BR>";
- }
- }
- ?>
- <?
- $op = $_POST['select'];
- $Quary_id = $_POST['id'];
- $pw = $_POST['passwd'];
- if ($op)
- {
- my_score($Quary_id,$pw);
- }
- ?>
复制代码
第一个score.htm档案是首页,透过表单POST传帐号 & 密码到Quary.php 作验证如果没问题就开启资料库 , 之后我想在Quary.php
开启后我做个下拉式表单选择查询国英数或是全部, 我想再利用 POST 方式从下拉式表单中取得值来表示要选择查询的科目 ...不过这边我用POST取得下拉式单表的值我想再把值传给函式让这函式show 出选的科目方式
单独传用这两参数都没问题
$Quary_id = $_POST['id'];
$pw = $_POST['passwd'];
我加上$op = $_POST['select']; // 就完全不能传递了, 一拿掉op = $_POST['select']; 又可以使用@@
我想知道是我哪边有错用吗??
谢谢
[ 本帖最后由 shihyu 于 2006-12-12 02:07 编辑 ] |
|