我使用URL從一個頁面傳遞行數據到另一個如何通過get方法方法捲曲陣列
echo "<td >
<a href='sessiondetails.php?docname={$key['DocName']}& HosName={$key['HosName']}& HosCode={$key['HosCode']}............}'>
More>>
</a></font>
</td>
</tr>";
在我的第二頁,我使用$_GET
的值賦給變量,是呼應運作良好。
但是當我將變量賦值爲數組值時,它不會傳遞值,我不明白爲什麼。
這裏是我的第二頁代碼:
<html>
<head>
<link href='style1.css' rel='stylesheet' type='text/css'>
<?php
$SpecializationId = $_GET['SpecialitionID'];
$DoctorNo = $_GET['DoctorNo'] ;
$day = $_GET['day'];
$date = $_GET['date'];
$HosCode = $_GET['HosCode'];
$hospital = $_GET['HosName'];
$doctor = $_GET['docname'];
$specialization = $_GET['SpecName'];
$baseurl = 'http://202.124.173.187/api/v1/doctorSessions';
$rawPOSTdata = array(
"hosID" => $HosCode,
"specID" => $SpecializationId,
"docNo" => $DoctorNo,
"day" => $day,
"date" => $date
);
$curl = curl_init($baseurl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
"Authorization: Bearer $atoken"
));
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($rawPOSTdata));
$response = curl_exec($curl);
curl_close($curl);
if($response) {
if (isset($result->error)) die($result->error_message);
/* Convert json data to array */
$arr=json_decode($response,true);
?>
"hosID"=>$hosCode,
沒有采取價值同時通過CURLOPT_CUSTOMREQUEST和CURLOPT_POST和CURLOPT_CUSTOMREQUEST堅持爲POST而CURLOPT_POST切換到CURLOPT_HTTPGET
爲什麼在URL params中的&和變量之間有空格?另外,你有沒有嘗試var_dump($ HosCode)來查看它是否有任何東西? –
從url中刪除空格,並檢查'var_dump($ _ GET)'看看你通過的是什麼 – phaberest
另外,我假設「............}」不在實際代碼中。 ... –