我正在尝试让我的PHP填充我的页面元素,但页面不会根据我在SQL的where子句中尝试的任何内容输出结果(即使它在我的服务器上运行。我不知道为什么当使用where参数运行此页面时(捕获已发布的变量)没有任何反应。如果您需要更多信息,请告诉我。
<?php
//start output buffering
ob_start('ob_gzhandler');
session_name('shipshapeLogin');
session_set_cookie_params(2*7*24*60*60);
session_start();
define('INCLUDE_CHECK',true);
require('connect.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Organization Profile</title>
<link rel="stylesheet" type="text/css" href="profile.css" media="screen" />
</head>
<body>
<?php
$businessName = $_POST['companies'];
echo $businessName;
//check if username or email is already registered
$query = "SELECT * FROM Businesses_profiles WHERE business_name = :businessName";
//now lets update what :user should be
$query_params = array(
':businessName' => $businessName,
);
try
{
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
}
//fetching all the rows from the query
$profileRow = $stmt->fetch();
while ($profileRow = $stmt->fetch())
{
?>
<h1>Name</h1>
<p><?php echo $profileRow['business_name'];?></p>
<h1>Description</h1>
<p><?php echo $profileRow['description'];?></p>
<h1>Address</h1>
<p><?php echo $profileRow['address'];?></p>
<h1>Phone</h1>
<p><?php echo $profileRow['contact_phone'];?></p>
<h1>Email</h1>
<p><?php echo $profileRow['contact_email'];?></p>
<?php
}
?>
</body>
</html>
<?php
//end output buffering
ob_end_flush();
?>
答案 0 :(得分:0)
我必须删除while循环上面的$ profileRow。
/fetching all the rows from the query
$profileRow = $stmt->fetch();**
while ($profileRow = $stmt->fetch())
{
?>