这是我的结果页面,我需要帮助将每家餐厅链接到 detail.php 页面。
我正在开发一个网站,该网站显示旧金山所有餐厅的健康检查分数、地址和违规情况。
第一页是我的索引页,它只是一个搜索栏,可以让您输入餐厅的名称或关键字。这将导致我的 results.php 页面获取所有数据并为您提供匹配示例的列表以供您搜索。我遇到的问题是,我必须从 results.php 页面将其链接到列出的每家餐厅的 details.php。然后详情页面会显示他们的健康检查分数,餐厅的地址和地图。
如何将餐厅链接到详细信息页面?
这是我的网站链接:http: //jfol.io/j426/s13/mariana/a07/
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A07</title>
<link href='http://fonts.googleapis.com/css?family=Armata' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="left-nav">
<a href="index.php">Home</a>
<a href="results.php">Restaurants</a>
<a href="details.php">Violations</a>
<a href="#">Scores</a>
</div>
<div id="main">
<?php
// load query
$query = "
SELECT businesses.business_id AS business_id,
businesses.name AS name,
inspections.score AS score,
inspections.date AS date,
inspections.business_id
FROM businesses
INNER JOIN inspections
ON businesses.business_id = inspections.business_id
WHERE businesses.name LIKE '%$business_name%'
ORDER BY businesses.name ASC
LIMIT $row_start, $pagination";
// output page header
echo "<h1> Restaurants </h1>";
// output query (debug)
//echo "<i>Debug:</i> " . $query . "<p></p>";
// execute query
$result = mysqli_query($db_connection,$query);
// grab count of records returned
$row_count = mysqli_num_rows($result);
// output record count
echo "Displaying records " . ($row_start + 1) . " to " . ($row_start + $pagination) . " <p></p>";
// advance pagination counter
$row_start = $row_start + $pagination;
// output pagination link
echo ("<p></p><a href=\"results.php\">First page</a> | <a href=\"results.php?row_start=" . $row_start . "\">Next " . $pagination . " records</a><p></p>");
// create table tag
echo ("<table>\n\n");
echo ("<tr class=\"header\">\n<td>Business Name</td><td>Inspection Score</td><td>Inspection Date</td></tr>\n");
// create row counter
$current_row = 0;
// loop through returned records
while ($row = mysqli_fetch_array($result))
{
// set variables
$business_id = $row["business_id"];
$business_name = ucwords(strtolower($row["name"]));
$inspection_score = $row["score"];
//$address = $row["address"];
$violation_date = date("n/j/Y",strtotime($row["date"]));
$inspection_date = date("n/j/Y",strtotime($row["date"]));
// output to screen
// echo($business_name . " / " . $violation_description . " / " . $violation_date . "<br />");
if ($current_row % 2 == 0)
{
$shading = "alternate ";
}
else
{
$shading = "";
}
echo ("<tr class=\"$shading\">\n\n");
echo("<td>\n\n" . $business_name . "</td>\n\n<td>\n\n" . $inspection_score . "</td>\n\n<td>\n\n" . $inspection_date . "</td>\n\n" );
echo ("</tr>\n\n");
$current_row++;
}
echo ("</table>\n\n");
// output pagination link
echo ("<p></p><a href=\"results.php\">First page</a> | <a href=\"results.php?row_start=" . $row_start . "\">Next " . $pagination . " records</a><p></p>");
?>`enter code here`
</div>
</body>
</html>