HTML $ _GET方法不起作用

时间:2014-05-17 13:22:55

标签: php html forms get

我正在尝试从我的某个页面中的列表中获取值。问题是它不显示它应该显示的值。举个例子,我有这些;

i)$ _GET ['name'] = a value
ii)$ handsome = $ _GET ['name']
iii)$ qq = mysql_query(“SELECT * FROM student where name ='$ handsome';”)

当我测试值检查时,$ _GET和$ handsome产生相同的结果(有效),但$ qq ['name']或从数据库中获取的任何其他值都不显示任何值。页面没有指定任何错误,它只是空的。

对不起,如果代码太长而且令人困惑。

<!DOCTYPE>
<?php

include 'include.php';
if(!empty($_GET))
{
    $name = $_GET['name'];
    $sqp = mysql_query("SELECT * FROM student WHERE name='$name'");
}

if($_SESSION['level'] == 'student' || $_SESSION['level'] == 'admin')
{
    if($_SESSION['level'] == 'student')
    {
        $us = $_SESSION['matric'];
    }
    if($_SESSION['level'] == 'admin')
    {
        $us = $_SESSION['user'];
    }

    $sql = mysql_query("SELECT * FROM student WHERE matric = '$us';");
    $sqq = mysql_query("SELECT * FROM place");
    $sqe = mysql_query("SELECT * FROM student");
    $sqc = mysql_query("SELECT * FROM student");
    $sol = mysql_fetch_array($sql, MYSQL_ASSOC);
}
else if($_SESSION['level'] == 'driver')
{
    header("location:signin.php");
}
?>
<html>
<head>      
    <script type="text/javascript" src="jquery-1.11.0.js"></script>
    <script type="text/javascript" src="jquery.carouFredSel-6.2.1.js"></script>
    <script type="text/javascript" src="jquery.carouFredSel-6.2.1-packed.js">                

</script>

    <link rel="stylesheet" type="text/css" href="sppb.css">
</head>

<body>

    <div class="container">
        <div class="span1">
            <div id="utm-logo" class="">
                <a href="signin.php"><img src="./picture/logo utm.jpg" width="15%" height="7%"/></a>
            </div>
        </div>
        <div class="span5">
            <div id="header">
                <img src="./picture/SPPB.jpg" width="66%" height="6%"/>
            </div>
        </div>
    </div>

    <?php
    if($_SESSION['level']=='student')
    {
    ?>
    <div class="container" style="padding-left:24%; padding-top:15%;">      
        <ul id="sort">
            <li id="list" class="clearfix">
                <div class="list_identifier">Name</div>
                <div class="list_value"><?php echo $sol['name'];?></div>
            </li>
            <li id="list" class="clearfix">
                <div class="list_identifier">Matric</div>
                <div class="list_value"><?php echo $sol['matric'];?></div>
            </li>
        </ul>
        <form method="post" action="updatestudent.php">
            <ul id="sirt">
                <li id="list" class="clearfix">
                    <div class="list_identifier">Password</div>
                    <div class="list_value"><input type="password" name="pass" placeholder="<?php echo $sol['pass'];?>"/></div>
                </li>
                <li id="list" class="clearfix">
                    <div class="list_identifier">Address</div>
                    <div class="list_value"><input type="text" name="addr" placeholder="<?php echo $sol['addr'];?>" style="width:100%;"/></div>
                </li>
                <li id="list" class="clearfix">
                    <div class="list_identifier">Mobile Number</div>
                    <div class="list_value"><input type="text" name="hp" placeholder="<?php echo $sol['hp'];?>"/></div>
                </li>
                <li id="list" class="clearfix">
                    <div class="list_identifier">Faculty</div>
                    <div class="list_value"><select name="faculty">
                        <?php while ($sel = mysql_fetch_array($sqq, MYSQL_ASSOC))
                        {
                        ?>
                                                <option value="<?php echo $sel['r_name'];?>"><?php echo $sel['r_name'];?></option>
                        <?php
                        }
                        ?>
                                            </select></div>
                </li>
                <li><input type="submit" name="submit"/>
                            <a href="driver2.php" name="clear" id="clear">Clear</a></li>
            </ul>                           
        </form>
    </div>
    <?php
    }
    if($_SESSION['level']=='admin')
    {
        if(empty($_GET))
        {
    ?>
    <form method="get" action="student.php">
    <div id="container">
        <ul id="sort">
            <li id="list">
                <div class="list_identifier"><p>Select Student</p></div>
                <div class="list_value"><select name="name">
    <?php
            while($hey = mysql_fetch_array($sqc, MYSQL_ASSOC))
            {
    ?>
                    <option value="<?php echo $hey['name']; ?>"><?php echo $hey['name']; ?></option>
    <?php
            }
    ?>
                    </select</div>
            </li>
            <li><input type="submit" name="submit" /></li>
        </ul>
    </div>
    </form>
    <?php
        }
        else
        {

    ?>
    <form method="get" action="student.php">
    <div id="container">
        <ul id="sort">
            <li id="list">
                <div class="list_identifier"><p>Select Student</p></div>
                <div class="list_value"><select name="name">
    <?php
            while($hey = mysql_fetch_array($sqc, MYSQL_ASSOC))
            {
    ?>
                    <option value="<?php echo $hey['name']; ?>"><?php echo $hey['name']; ?></option>
    <?php
            }
    ?>
                    </select</div>
            </li>
            <li><input type="submit" name="submit" /></li>
        </ul>
    </div>
    <div style="padding-top:25%"><?php echo $_GET['name']; echo $name; echo $sqp['name'];?></div>

    </form>

    <div class="container" style="padding-left:24%; padding-top:15%;">      
        <ul id="sort">
            <li id="list" class="clearfix">
                <div class="list_identifier">Name</div>
                <div class="list_value"><?php echo $sqp['name'];?></div>
            </li>
            <li id="list" class="clearfix">
                <div class="list_identifier">Matric</div>
                <div class="list_value"><?php echo $sqp['matric'];?></div>
            </li>
        </ul>
        <form method="post" action="updatestudent.php">
            <ul id="sirt">
                <li id="list" class="clearfix">
                    <div class="list_identifier">Password</div>
                    <div class="list_value"><input type="password" name="pass" placeholder="<?php echo $sqp['pass'];?>"/></div>
                </li>
                <li id="list" class="clearfix">
                    <div class="list_identifier">Address</div>
                    <div class="list_value"><input type="text" name="addr" placeholder="<?php echo $sqp['addr'];?>" style="width:100%;"/></div>
                </li>
                <li id="list" class="clearfix">
                    <div class="list_identifier">Mobile Number</div>
                    <div class="list_value"><input type="text" name="hp" placeholder="<?php echo $sqp['hp'];?>"/></div>
                </li>
                <li id="list" class="clearfix">
                    <div class="list_identifier">Faculty</div>
                    <div class="list_value"><select name="faculty">
                        <?php while ($sel = mysql_fetch_array($sqq, MYSQL_ASSOC))
                        {
                        ?>
                                                <option value="<?php echo $sel['r_name'];?>"><?php echo $sel['r_name'];?></option>
                        <?php
                        }
                        ?>
                                            </select></div>
                </li>
                <li><input type="submit" name="submit"/>
                            <a href="student.php" name="clear" id="clear">Clear</a></li>
            </ul>                           
        </form>
    </div>
    <?php
    }
    }
    ?>

    <div id="nav-menu">
        <div id="menu_wrapper">
            <ul class="menu">
                <li class="span2"><a href="signin.php">Home</a></li>
                <li class="span3"><a href="#">Map</a>
                    <div class="dropdown_1column">
                        <ul class="canvas">
                            <li><a href="map1.php">Route 1</a></li>
                            <li><a href="map2.php">Route 2</a></li>
                            <li><a href="map3.php">Route 3</a></li>
                            <li><a href="map4.php">Route 4</a></li>
                            <li><a href="map5.php">Route 5</a></li>
                            <li><a href="map6.php">Route 6</a></li>
                        </ul>
                    </div>
                </li>
                <li class="span4"><a href="info.php">Information</a>
                </li>
            </ul>
        </div>
        <div id="menu_wrapper">
            <ul class="menu">
                <li class="span6"><a href="#">Update</a>
                    <div class="dropdown_1column">
                        <ul class="canvas">
                            <li><a href="student.php">Details</a></li>
                        </ul>
                    </div>
                </li>
                <li class="span7"><a href="logout.php">Logout</a></li>
            </ul>
        </div>
    </div>      
</body>
</html>

我想知道出了什么问题。在此之前(在较小的缩放页面上),$ _GET始终有效。请帮帮我。提前谢谢大家。

0 个答案:

没有答案