doukuangxun5382 2015-02-27 04:15
浏览 18
已采纳

单选按钮获取数据[关闭]

I'm attempting to get two different radio buttons to sort data. I have the data coming up, but the radio buttons are non functional. I'm not getting any errors or anything either, so I'm completely at a loss...

Any help would be greatly appreciated!

<?php 
  session_start();
  $user = $_SESSION['user']; 
  if(!isset($user)){
    header("Location:login.php");
  }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>WDD 420 Course Project</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="_js/jquery-1.7.2.min.js"></script>
<script src="_js/nav1.1.min.js"></script>
<script>
$(document).ready(function() {
 $("#nav_bar").navPlugin({
   'itemWidth': 150,
   'itemHeight': 30,
   'navEffect': "slide",
   'speed': 250
 });
});
</script>
</head>
<body>
<div class="container">
  <div class="header">
    <div class="logo">
      <a href="index.html"><img src="images/mylogo.jpg" alt="Logo for    the Virginia Easter Seals' spring marathon. Home link"></a>
    </div>
    <nav id="navigation">
    <ul id="nav_bar">
    <li><a target="_self" href="index.html">Home </a></li>
    <li><a target="_self" href="signup.php">Sign Up</a></li>
    <li><a target="_self" href="refer.php">Refer A Friend</a></li>
    <li><a target="_self" href="login.php">Login</a></li>
    <li><a target="_self" href="report.php">Report</a></li>
    </ul>
    </nav>
  </div>

 <div class="content">
  <form method="post" name="form4" id="form4" action="">
  <label for="submit_sort">Sort By: </label></th><td>
          <input name="submit_sort" type="radio" id="lname" value="lname">
          <label for="lname">Last Name</label>
          <input name="submit_sort" type="radio" id="distance" value="distance">
          <label for="distance">Distance</label>
      </form>
  <table width="100%" cellpadding="5">
    <tr><th>First Name:</th><th>Last Name:</th><th>Email:</th><th>Distance:</th></tr>
    <?php
    include('inc/dbuser.php');
    $select = "SELECT fname, lname, email, distance FROM runner ORDER BY lname";
    $result = mysqli_query($lrconnect, $select) or die ('Oops! '.mysqli_error($lrconnect));

    if(isset($_POST['submit_sort'])){
        $radio = $_POST['submit_sort']; 
        if($radio =='lname'){
          $select = "SELECT fname, lname, email, distance FROM runner ORDER BY lname";}
        else if($radio =='distance'){
          $select = "SELECT lname, fname, email, distance FROM runner ORDER BY distance";}
          $result = mysqli_query($lrconnect, $select) or die('Invalid Query! '.mysqli_error($lrconnect));
        }

      while($row = mysqli_fetch_assoc($result)) {
        echo '<tr><td>'.$row['fname'].'</td>';
        echo '<td>'.$row['lname'].'</td>';
        echo '<td>'.$row['email'].'</td>';
        echo '<td>'.$row['distance'].'</td></tr>';
      }

    ?>
  </table>
  </div>
  • 写回答

1条回答 默认 最新

  • doujue1246 2015-02-27 04:31
    关注

    Posting this to close the question.

    You don't have a submit button, so add the following to your form:

    <input type="submit" name="submit" value="Submit">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置