Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将id传递到另一个页面_Php_Jquery_Html_Ajax_Parameter Passing - Fatal编程技术网

Php 如何将id传递到另一个页面

Php 如何将id传递到另一个页面,php,jquery,html,ajax,parameter-passing,Php,Jquery,Html,Ajax,Parameter Passing,我有两页, 这个==>\u gradeviewer.php: <?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(

我有两页, 这个==>\u gradeviewer.php:

<?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>

伊万加利肯·斯科尔::Aees历史
函数showUser(str,aa)
{
如果(str==“”)
{
document.getElementById(“txtHint”).innerHTML=“”;
回来
}
if(window.XMLHttpRequest)
{//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}
其他的
{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById(“txtHint”).innerHTML=xmlhttp.responseText;
}
}
open(“GET”、“getuser.php?q=“+str+”&aa=“+aa,true”);
xmlhttp.send();
}


课程信息将列在这里。

此页面==>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变量从第一页传递到另一页, 地址栏看起来是../\u gradeviewer.php?page=\u gradeviewer&Id=161
因此,我想将id传递给getuser.php。

因为您已经在使用jQuery,所以请尝试$.get

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


函数showUser(str,aa)
{
如果(str!='')
{
$.get('getuser.php',{q:str,aa:aa},函数(数据){
$('#txtHint').html(数据);//通过数据处理结果
});
}
}

您可能希望将代码精简一点,只显示与问题相关的代码。
<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>