我是一名PHP新手,因此請體諒。
我試圖通過URL將doc_id(在下面的代碼中)傳遞給另一個頁面。不幸的是,在地址欄顯示出來,當我點擊這個鏈接,是DOC_ID =
echo'<td><a href="view_profile.php?doc_id='.$row[doc_id].'" onclick="return confirm(\'Do you wish to view this record?\');">View Profile</a></td>';
此鏈接實際工作的其他頁面。我無法弄清爲什麼它不能在我現在使用的那個上運行。有任何想法嗎?
任何建議將不勝感激。
該行是這樣的:
if($SearchBySpec) { $query="SELECT * FROM doctor where specialization='$SearchBySpec'"; $result=mysql_query($query) or die('Error executing select query'.mysql_error());
echo'<table border="1" cellspacing="1">'; echo'<tr align="center">'; echo'<td bgcolor=#81F7D8 width="80" class="auto-style2"><strong>Specialization</strong></td>'; echo'<td bgcolor=#81F7D8 width="80" class="auto-style2"><strong>Last Name</strong></td>'; echo'<td bgcolor=#81F7D8 class="auto-style2" style="width: 103px"><strong>First Name</strong></td>'; echo'<td bgcolor=#81F7D8 width="80" class="auto-style2"><strong>Middle Initial</strong></td>'; echo'<td bgcolor=#81F7D8 width="90" class="auto-style2"><strong>School</strong></td>'; echo'<td bgcolor=#81F7D8 width="80" class="auto-style2"><strong>Hospital Assigned</strong></td>';
while($row=mysql_fetch_array($result)) { echo "<tr align=center>"; echo "<td>$row[specialization]"; echo "<td>$row[last_name]"; echo "<td>$row[first_name]"; echo "<td>$row[middle_name]"; echo "<td>$row[school]"; echo "<td>$row[hospital_assigned]";
}
//echo"<td><a href='view_profile.php?doc_id=".$row[doc_id]."'>View Profile</a></td>"; echo'<td><a href="view_profile.php?doc_id='.$row[doc_id].'" onclick="return confirm(\'Do you wish to view this record?\');">View Profile</a></td>'; //echo'<td><a href="view_profile.php?doc_id='.$row[doc_id].'" onclick="return confirm(\'Do you wish to view this record?\');">View Profile</a></td>'; echo "<tr><td>There are ". mysql_num_rows($result). " record(s)found.</td></tr>"; echo "</table>" ;
}
好吧,$行不包含你認爲它包含的內容 - var_dump($ row)並且看看你得到了什麼,並且確保你已經啓用了所有的錯誤報告。 – 2012-03-11 10:18:10
聽起來像$ row [doc_id]是空的。如果你var_dump($ row)'',你會得到什麼? – 2012-03-11 10:18:41
嘗試顯示$ row [doc_id]。它顯示了什麼? – Oleg 2012-03-11 10:19:37