当我在第二页中使用GET方法时,我使用GET方法从一个页面获取的值保留在第二页中

时间:2018-04-03 09:42:10

标签: php

这是我的第一页nfdata.php

<form action='drop.php' method='get'>
<tr>
<td ><input type="radio" name="radio" value="DGSTO 1">DGSTO 1</td>
<td><input type="submit" name="sub" value="Submit">

这是我的第二页drop.php

<html>
<form id="form" action"drop.php" method="get">
    <select id="office" name="code">

	<?php
     include 'sql.php';
     if($div = $_GET['radio'])
	 {
	                 $div = $_GET['radio'];
	                    $query="SELECT off_code_nf From non_filer where div_code_nf='$div' group by off_code_nf";
                        $sql = mysql_query($query);
                       // $row = mysql_fetch_assoc($sql);
					   //echo "<select name='to_user'>";
                            while ($row = mysql_fetch_assoc($sql))
							{
                                echo "<option value='". $row['off_code_nf'] ."'>" .$row['off_code_nf'] ."</option>" ;
                            }
                        //echo "</select>" ;
     }
	
 ?>
 </select>
 <input type="submit" name="sub" value="Submit" />
 <br><br>
 
 <?php
    include 'sql.php';
	$inventory = $_GET['code'];
	$query= "SELECT * FROM non_filer WHERE off_code_nf = '$inventory' "; 
	$result = mysql_query($query);
	if ($inventory = $_GET['code'])
	   {	
         echo "<table border='1'>
               <tr>
               <th>State Code</th>
               <th>GSTIN</th>
               
			   </tr>";
	   }
	while ( $row = mysql_fetch_assoc( $result ) )
					{
						    $a = $row['state_code_nf'];
							$b = $row['gstin_nf'];
							Print("<tr >");
						   print("<td >$a</td>");
						   print("<td >$b</td>");
					}
			print("</table>");
?>
</html>
我在nfdata.php中使用了get方法,并在第二页drop.php中获取了单选按钮的值,它从数据库中选择数据。但是从下拉列表中选择值后当我点击drop.php页面中的提交时,下拉列表的值不会出现,因为有新的get方法。那么如何保持第一个get方法的值

1 个答案:

答案 0 :(得分:0)

<html>
<form id="form" action"drop.php" method="get">
    <select id="office" name="code">

	<?php
     include 'sql.php';
$radioVal = $_GET['radio'];
     if($div = $_GET['radio'])
	 {
	                 $div = $_GET['radio'];
	                    $query="SELECT off_code_nf From non_filer where div_code_nf='$div' group by off_code_nf";
                        $sql = mysql_query($query);
                       // $row = mysql_fetch_assoc($sql);
					   //echo "<select name='to_user'>";
                            while ($row = mysql_fetch_assoc($sql))
							{
                                echo "<option value='". $row['off_code_nf'] ."'>" .$row['off_code_nf'] ."</option>" ;
                            }
                        //echo "</select>" ;
     }
	
 ?>
 </select>
<input type="hidden" name="radio_val" value="<?=$radioVal?> />
 <input type="submit" name="sub" value="Submit" />
 <br><br>
 
 <?php
    include 'sql.php';
	$inventory = $_GET['code'];
	$query= "SELECT * FROM non_filer WHERE off_code_nf = '$inventory' "; 
	$result = mysql_query($query);
	if ($inventory = $_GET['code'])
	   {	
         echo "<table border='1'>
               <tr>
               <th>State Code</th>
               <th>GSTIN</th>
               
			   </tr>";
	   }
	while ( $row = mysql_fetch_assoc( $result ) )
					{
						    $a = $row['state_code_nf'];
							$b = $row['gstin_nf'];
							Print("<tr >");
						   print("<td >$a</td>");
						   print("<td >$b</td>");
					}
			print("</table>");
?>
</html>

点击第二页上的提交按钮

时使用$ _GET ['radio_val']