我有一个显示链接的页面,所以当我单击该链接时,它应该将我带到另一个页面并查询数据库,以便我只能看到该特定链接的信息。但是现在它给了我一个问题,它与我在其他程序中使用的代码相同。我已经尝试了将近 2 个小时来解决这个问题。请下面是任何可以帮助您的代码。
First piece of code or page
<?php
$selector1 =("SELECT job_id, job_title, job_description,
job_category, wantORoffering, address, cell, email, date_registered,
user_id from h2s_job ORDER BY date_registered DESC LIMIT $offset, $rowsperpage");
$result_selector=$con->prepare($selector1);
$result_selector->execute();
while($row = $result_selector->fetch(PDO::FETCH_ASSOC)){
#substring
$job_description = $row['job_description'];
$job_description = wordwrap($job_description , 200);
$job_description = explode("\n", $job_description );
$job_description = $job_description [0] . '...';
#substring
echo '<a href="jobdetails.php?job_id=$job_id"><div id="record" id ="record-">
<strong class="pic"><img src="images/nopic.png" ></strong>
<strong class="job_title"><h4>',$row['job_title'],'</h4></strong></br>
<strong class ="desc"><p>',$job_description,'</p></strong></br>
<strong class="contact"><p>',$row['cell'],'</strong></br>
<strong class="time"><p>',$row['date_registered'],'</strong></br>
</div></a>';
}?>
Second page
<?php
$selector =("SELECT job_title, job_description,
job_category, wantORoffering, address, cell, email, date_registered,
user_id FROM h2s_job WHERE job_id =".$_GET['job_id']);
$result_selector=$con->prepare($selector);
$result_selector->execute();
while($row = $result_selector->fetch(PDO::FETCH_ASSOC)){
#substring
$job_description = $row['job_description'];
echo '<div id="record" id ="record-">
<strong class="pic"><img src="images/nopic.png" ></strong>
<strong class="job_title"><h4>',$row['job_title'],'</h4></strong></br>
<strong class ="desc"><p>',$job_description,'</p></strong></br>
<strong class="contact"><p>',$row['cell'],'</strong></br>
<strong class="time"><p>',$row['date_registered'],'</strong></br>
</div></a>';
}
?>
我得到的错误
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column '$job_id' in 'where clause'' in C:\wamp\www\houseCurrent\jobdetails.php:98 Stack trace: #0 C:\wamp\www\houseCurrent\jobdetails.php(98): PDOStatement->execute() #1 {main} thrown in C:\wamp\www\houseCurrent\jobdetails.php on line 98