2013-03-08 19 views
0

所以我的主頁上我有

<?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我嘗試使用發佈的想法作爲答案,但似乎並沒有爲我工作。

+3

我不明白這個問題。 js在哪裏?以上都是PHP。 – mkaatman 2013-03-08 23:09:31

+0

您是否嘗試過使用Ajax? – kabuto178 2013-03-08 23:09:40

+0

@mkaatman該文件是<?php require_once()?>在我的.js.php文件中 – Datsik 2013-03-08 23:11:55

回答

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。

由於您在Findme.php中包含findme.js.php文件,該腳本也將填充$ _GET。希望這有助於:)

+0

那麼在我的實際頁面上,我是否會在腳本src中調用它或包括 – Datsik 2013-03-09 01:33:57

+0

我編輯了我的原始文章試圖做你說的話你能告訴我我做錯了什麼嗎? – Datsik 2013-03-09 01:46:38

+0

如果有什麼錯誤,你會得到什麼? – Andrew 2013-03-09 10:09:45