2014-04-26 36 views
0

我有2页, 这一个==> _gradeviewr.php:如何将ID传递到另一个页面

<?php 
require_once ("include/config.php"); 
require_once ("include/Connection.php"); 
require_once("include/functions.php"); 
error_reporting(E_ERROR | E_PARSE); 
ob_start(); 

if (!isset($_SESSION)) { 


    session_start(); 


    } 
$query2 = "SELECT * FROM subjects where SbjID=".$_GET['Id'];//echo $query; 
$result2 = mysql_query($query2, $connection); 

while ($row2 = mysql_fetch_array($result2)){ 
$title=$row2['SbjTitle']; 
$text=$row2['SbjText']; 
$id=$row2['SbjID']; 

?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 
<head> 
<link href="css/tabcontent.css" rel="stylesheet" type="text/css" /> 
<script src="js/tabcontent.js" type="text/javascript"></script> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Evangalican Scool :: Aees History</title> 
<!-- Stylesheet --> 
<link href="css/style.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" /> 
<link rel="stylesheet" type="text/css" href="css/jquery.fancybox-1.3.4.css" media="screen" /> 
<!-- Javascript --> 
<script src="js/jquery.min.js" type="text/javascript"></script> 
<script src="js/ddsmoothmenu.js" type="text/javascript"></script> 
<script src="js/contentslider.js" type="text/javascript"></script> 
<script type="text/javascript" src="js/jcarousellite_1.0.1.js"></script> 
<script type="text/javascript" src="js/jquery.easing.1.1.js"></script> 
<script type="text/javascript" src="js/cufon-yui.js"></script> 
<script type="text/javascript" src="js/DIN_500.font.js"></script> 
<script type="text/javascript" src="js/menu.js"></script> 
<script type="text/javascript" src="js/tabs.js"></script> 
<script type="text/javascript" src="js/jquery.mousewheel-3.0.4.pack.js"></script> 
<script type="text/javascript" src="js/jquery.fancybox-1.3.4.pack.js"></script> 
<script> 
function showUser(str,aa) 
{ 
if (str=="") 
    { 
    document.getElementById("txtHint").innerHTML=""; 
    return; 
    } 
if (window.XMLHttpRequest) 
    {// code for IE7+, Firefox, Chrome, Opera, Safari 
    xmlhttp=new XMLHttpRequest(); 
    } 
else 
    {// code for IE6, IE5 
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
xmlhttp.onreadystatechange=function() 
    { 
    if (xmlhttp.readyState==4 && xmlhttp.status==200) 
    { 
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText; 
    } 
    } 

xmlhttp.open("GET","getuser.php?q="+str+"&aa="+aa,true); 

xmlhttp.send(); 
} 
</script> 
</head> 
<body> 
<?php if ($_GET['Id']==$id) {?> 
<div id="bg"> 
<div id="wrapper_sec"> 
     <?php include "inc/Headar.php";?> 
      <div id="content_section"> 
        <?php include "inc/news_update.php";?> 

         <div class="clear">&nbsp;</div> 
           <p> 
           <?php  

     echo " <div id='ontent_section'> 
       <div class='col2'>"; 
         include 'inc/Advertisement.inc'; 
         echo " 
         </div></div> 
        <h2 class='hpad'>"; 
        echo $title; 
        echo "</h2> 
        <p class='stext'>";echo $text;echo "</p> "; } 
        ?></p> 
        <br> 

        <form > 

<select name="users" onchange="showUser(this.value,aa)"> 
<?php 
$aa=$_GET['Id']; 
$sqllst = "SELECT DISTINCT en FROM cslst"; 
$resultlst = mysql_query($sqllst); 


while ($row = mysql_fetch_array($resultlst)) { 
    echo "<option value='" . $row['en'] . "'>" . $row['en'] . "</option>"; 
} 



?> 


</select> 



<br> 
<div id="txtHint"><b>Course info will be listed here.</b></div> 


           </p> 
           <p>&nbsp; </p> 
    <div class="clear"></div></div></div> 
     <div class="clear"></div> 
    </div> 
</div>  
</form> 
<!-- Footer Section --> 
<?php include "inc/Footer.inc";?> 

    </div> 
</div> 

     </div> 
    </div> 
    <?php } 

    ?> 

</body> 
</html> 

与此页==> getuser.php:

<?php 
include("_gradeviewr.php"); 
require_once ("include/config.php"); 
require_once ("include/Connection.php"); 
require_once("include/functions.php"); 
error_reporting(E_ERROR | E_PARSE); 
ob_start(); 
$q = $_GET['q']; 

$aa=$_GET['aa']; 


$con = mysqli_connect('localhost','root','','evang_www'); 
if (!$con) 
    { 
    die('Could not connect: ' . mysqli_error($con)); 
    } 

mysqli_select_db($con,"evang_www"); 
$sql="SELECT * FROM uploaded WHERE sbid='".$aa."' AND subject = '".$q."'" ; 

$result = mysqli_query($con,$sql); 


echo "<table border='1'> 
<tr> 

<th>subject</th> 
<th>Date from</th> 
<th>Date To</th> 
<th>filename</th> 
<th>Download</th> 
</tr>"; 

while($row = mysqli_fetch_array($result)) 
    { 

    echo "<tr>"; 
    echo "<td>" . $row['subject'] . "</td>"; 
    echo "<td>" . $row['datefrom'] . "</td>"; 
    echo "<td>" . $row['dateto'] . "</td>"; 
    echo "<td>" . $row['filename']. "</td>"; 
    echo '<td><a href=./upload/' . $row['filename'] . '>[Download]</a></td>'; 
    echo "</tr>"; 

    } 
echo "</table>"; 


mysqli_close($con); 
?> 

..如何将ID变量从第一页传递到另一页, 地址栏看起来像../_gradeviewr.php?page=_gradeviewr & Id = 161 所以我想通过ID到getuser.php 。

+0

您可能要修剪下来的代码位,显示只有与问题相关的代码。 – Utkanos

回答

0

由于您使用jQuery已经然后再试$不用彷徨

示例代码(将此代码在页面的底部)

<script> 

    function showUser(str,aa) 
    { 

    if(str != '') 
    { 


     $.get('getuser.php',{q:str,aa:aa},function (data) { 

       $('#txtHint').html(data); // handle the result via data 

     }); 


    } 

    } 

</script> 
相关问题