所以在我的主页上我有
<?php
require_once('config.inc.php');
require_once($rootdir . $dirsubfolder . 'navbar.php');
?>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=true"></script>
<script src="php/findme.php"></script>
<div class="hero hero-unit" style="padding: 0; padding-top: 3%;">
<div id="search" class='input-append'><input id="setNewDistance" class="span3" type="text" placeholder="Set Distance In Meters">
<button class='btn btn-info' id="changeDistance" type="submit">Search
</button></div>
<p class='alert-info' id="stopsfoundtext"></p>
<div id="gmaps"></div>
</div>
<?php
require_once($rootdir . $dirsubfolder . 'footer.php');
?>
然后在Findme.php中我有
<?php
/* Include neccesary files */
require_once('config.inc.php');
$gPlantSite = $_GET['plantsite'];
/* Connect to Database */
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_BASE);
/* Prepare Database statement */
if ($stmt = $mysqli -> prepare("SELECT route_id, Latitude, Longitude, Title, Weekday_Day, Weekend_Day, ADO_Day, Weekday_Night,
Weekend_Night, ADO_Night, Direction_Of_Bus,
What_Shift FROM Routes WHERE Plant_Site = ?")) {
/* Bind param to search for */
$stmt -> bind_param('s', $gPlantSite);
/* Execute and hope it works */
$stmt -> execute();
/* Bind the results to variables */
$stmt -> bind_result($gRoute_Id, $gLatitude, $gLongitude, $gTitle, $gWeekdayDay, $gWeekendDay, $ADODay,
$WeekdayNight, $WeekendNight, $ADONight, $gDirectionOfBus, $gwhatShift);
/* Leave connection open so that it may be queryd on the client side */
include "../js/findme.js.php";
}
?>
但它似乎仍然没有从php文件中获取$ _GET,任何人都有任何想法我在这里没有想法
我只是需要它来获取$ _GET我尝试使用发布的答案作为答案,但这似乎对我不起作用。
答案 0 :(得分:1)
您可以将js.php文件包含在此文件中。
如果你这样做:
// .. other code ..
$stmt->bind_param('s', $gPlantSite); // at the bottom..
include "js.php"; // at the end of the file
然后你也可以在这个文件中访问$ _GET。
修改强>
目前无法正常工作:
<script src="php/findme.php"></script>
这意味着你将执行findme.php脚本,但是你没有在这里提供任何查询字符串,因此$ _GET将始终为空。
通过$ _GET提供任何内容,您需要提供给脚本标记,如下所示:
<script src="php/findme.php?plantsite=something"></script>
$ _ GET ['plantsite']将在Findme.php中填充值'something'。
当您在Findme.php中包含findme.js.php文件时,该脚本也会填充$ _GET。希望这会有所帮助:)