duanliang8464 2016-11-03 16:24
浏览 40

如何在重定向的php页面中使用下拉数据作为参考?

I have lots of PHP pages, and i have a seesion started already, i also have a php page that contains a dropdown menu from the database.

Now i want to use the data selected in the dropdown of my current page as a reference for populating the dropdown i have in the next page, but i dont kw how to do that: this is my code for the first php page :

enter  <form method = "get" action = "register.php">
  <label>Choose Department:</label><br>
   <select name = "select" class= "textfields" id= "">

       <option id = "">Choose department</option>

   <?php
   //connect to db 
  $connect = mysqli_connect('localhost', 'root', '', 'guu portal') or die ('cant you just connect to the database');                  

  $query = "select * from departments";
  $result = mysqli_query($connect,$query);

  while($row = mysqli_fetch_array($result)){  
      $take = $row['id'] ;                
 ?>       
  <option id = "<?php echo $take; ?>"><?php echo $row['departments']; ?></option>
  <?php } 
  ?>



here

now dis is working, buh i want to use the $take as reference in this other page, here is the code:

enter  <form class= "form" role = "form" method="post" action=""> 
         <fieldset><legend>Course Registration</legend> <div class = "col-sm-12"><label>code</label><select name ="select"> <option id ="">choose</option>








<?php 
$connect = mysqli_connect('localhost', 'root', '', 'guu portal') or die ('cant you just connect to the database');

$query = "select * from registration";

$result = mysqli_query($connect,$query); 

while($row = mysqli_fetch_array($result)){ 
?>
<option id = "<?php echo $row['departments'];?>"><?php echo $row['course_code']; ?></option>
<?php }
?> 
</select>

<label>title</label>
<select name= "select"> 
<option id ="">---</option>
<?php $query = "select * from registration";
$result = mysqli_query($connect,$query); 

while($row = mysqli_fetch_array($result)){ 
 ?>
<option id = "<?php echo $row['departments'];?>"><?php echo $row['title']; ?></option>          
<?php }
?>
</select>

<label>unit</label>
<select name= "select"> 
<option id ="">---</option>
<?php $query = "select * from registration";
$result = mysqli_query($connect,$query); 
while($row = mysqli_fetch_array($result)){ 
?>
<option id = "<?php echo $row['departments'];?>"><?php echo $row['unit']; ?></option>          
<?php }
?>
</select>  

here

so pls how do i do that?

  • 写回答

1条回答 默认 最新

  • dpzr52746 2016-11-03 16:47
    关注

    If I understand you correctly, you are trying to pass $row['departments'] to the second file.

    You can either use ajax call or pass it through the url.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP