我正在尝试获取id并将其存储在变量中,但它向我显示了 变量没有定义,查询因为变量而没有执行,我不明白为什么。
include 'connect.php';
if(isset($_GET['OrgName']))
{
$file=$_GET['OrgName'];
$sql="SELECT oraganzation.OrgName,oraganzation.City,oraganzation.OrgEmail,oraganzation.OrgPhoneNO, oraganzation.Workfield, oraganzation.Trainingrecruitment, oraganzation.WebsiteLink,Student_comments.comment
FROM oraganzation , Student_comments
WHERE oraganzation.OrgName=$file AND oraganzation.OrgID=Student_comments.OrgID ";
}
$result= mysqli_query($con,$sql) or die ("could not found; ".mysqli_error ($con));
while ($row=mysqli_fetch_array($result) )
{
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> <strong>
Comments: </strong> " .$row['comment']. "<br>" ;
}
这是我上一页的代码,我把一个href用于获取名称
$sql="SELECT OrgName, City, OrgEmail, OrgPhoneNO, Workfield, Trainingrecruitment, WebsiteLink,OrgID
FROM oraganzation";
$result= mysqli_query($con,$sql) or die ("could not found; ".mysqli_error($con));
while ($row=mysqli_fetch_array($result) )
{
?>
<div class="content ">
<a href="training.php?name=<?php echo $row['OrgName'] ?> "><?php echo $row['OrgName'] ;?> </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 recruitment:</strong> " . $row['Trainingrecruitment'].
"<br> <strong>
Website Link: </strong> " . $row['WebsiteLink'].
"</div> ";} ?>
答案 0 :(得分:0)
$ sql仅在
时定义if(isset($_GET['OrgName']))
你应该在$ sql之后移动结束括号,运行查询后,或者即使没有设置OrgName也要定义$ sql