2017-08-01 74 views
-1

我有2個包含$ _GET $ _POST的代碼,並且結果沒有出現在頁面中,當我編寫var_dump($ _ GET)時,它打印出正確的值,但我不「知道爲什麼沒有在這裏頁面顯示的代碼是

<?php    
    $sql="SELECT OrgName, City, OrgEmail, OrgPhoneNO, Workfield, Trainingrequirements, WebsiteLink,OrgID 
    FROM oraganzation"; 

    $result= mysqli_query($con,$sql) or die ("could not found; 
     ".mysqli_error($con)); 

     while ($row=mysqli_fetch_array($result)) 
     { 
      $name=$row['OrgName']; 
      ?> 

      <div class="content "> 
    <a href="training.php?name=<?php echo $name ?> "><?php echo $name;?> 
        </a> 
      <?php 
     echo "<br><strong> City : </strong>". $row['City']. 
     "<br><strong> 
     Email: </strong>" . $row['OrgEmail']. 
     "<br><strong> 
     PhoneNO: </strong>". $row['OrgPhoneNO']. 
     "<br> <strong> 
    Work field: </strong> " . $row['Workfield']. 
     "<br><strong> 
     Training requirements:</strong> " . $row['Trainingrequirements']. 
     "<br> <strong> 
     Website Link: </strong> " . $row['WebsiteLink']. 


      "</div> ";} ?>  

這裏是$ _GET在其他頁:

 var_dump($_GET); 
    if (isset($_GET['$name'])) 
     { 
     $namet=$_GET['$name']; 


    $sql="SELECT OrgID , OrgName, City, OrgEmail, OrgPhoneNO, Workfield, Trainingrecruitment, WebsiteLink 
      FROM oraganzation 
      WHERE OrgName='$namet'"; 

     $result= mysqli_query($sql) or die ("could not found; ".mysqli_error($con)); 

     while ($row=mysqli_fetch_array($result)) 
     { 
     $id=$row['OrgID']; 
     echo "<br><strong> Name : </strong>". $row['OrgName']. 
     "<br><strong> 
     <br><strong> City : </strong>". $row['City']. 
     "<br><strong> 
     Email: </strong>" . $row['OrgEmail']. 
    "<br><strong> 
    PhoneNO: </strong>". $row['OrgPhoneNO']. 
    "<br> <strong> 
    Work field: </strong> " . $row['Workfield']. 
    "<br><strong> 
    Training recruitment:</strong> " . $row['Trainingrecruitment']. 
    "<br> <strong> 
     Website Link: </strong> " . $row['WebsiteLink']."<br>" ; 
      } 

}

輸出顯示此

 array(1) { ["name"]=> string(14) "AsimArabCenter" } 
+1

'$ _GET [ '$名稱'] ','name'前面有'$'。 –

+0

_此問題是由於無法再現的問題或簡單的印刷錯誤造成的。雖然類似的問題可能在這裏討論,但這個問題的解決方式不太可能有助於未來的讀者。這通常可以通過識別並仔細檢查發佈之前重現問題所需的最短程序來避免._ – mplungjan

+0

您正在使用變量作爲數組鍵!瞭解數組 –

回答

4

你正試圖從GET變量來訪問你的數據是這樣

$namet=$_GET['$name']; 

有一個在拿不出$名稱,它應該是

$namet=$_GET['name'];