在主页中,我希望通过以下链接打开详细信息页面:
<td><a href=details.php?c_id=<?php echo $c_id ?> ><img src="./images/<?php echo $row['cfilename']; ?>" width="90" height="120" alt="" /></a></td>
和 details.php 代码:
<?php
$mysqli = new mysqli("localhost", "joseph", " ", "collectionsdb");
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
// get value of object id that was sent from address bar
//$c_id = mysql_real_escape_string(c_id);
    /* Create the prepared statement */
    if ($stmt = $mysqli->prepare("SELECT c_id,ctitle,csubject,creference,cyear,cobjecttype,cmaterial,ctechnic,cwidth,cheight,cperiod,cmarkings,cdescription,csource,cartist,cfilename FROM collections WHERE c_id=$c_id")) {    
    /* Execute the prepared Statement */
    $stmt->execute();
    /* Bind results to variables */
    $stmt->bind_result($c_id,$ctitle,$csubject,$creference,$cyear,$cobjecttype,$cmaterial,$ctechnic,$cwidth,$cheight,$cperiod,$cmarkings,$cdescription,$csource,$cartist,$cfilename);
    /* fetch values */
    while ($rows = $stmt->fetch()) {
     // display records in a table
    // and the table of results  
?>  
但是,当我按下链接时, details.php 会打开所有数据。我希望只打开特定 $c_id 变量的数据。我不确定为什么它没有被传递到详细信息页面。在我放置 WHERE 条件的方式中,我收到 c_id 的未定义变量错误。
请问,我错过了什么?
约瑟夫