Forum Moderators: coopster
<?php
$list=null;
$query = "select id,state from table order by state asc";
$result=mysql_query($query);
while ($row=mysql_fetch_array($result)) {
$list .= "<li><a href=\"details.php?st=\"" . $row['id'] . "\">" . $row['state'] . "</a></li>\n";
}
echo "<html><head><title>State List</title></head>
<body><h1>State List</h1>";
if ($list) { echo "<ul>$list</ul>"; }
else { echo "<p>No states to display</p>"; }
echo "</body></html>";
?>
<?php
if (isset($_GET['st']) and is_numeric($_GET['st']) and ($_GET['st']>0)) {
$query = "select city,state,description from table where id=" . $_GET['st'];
$result=mysql_query($query);
if ($row=mysql_fetch_array($result)) {
$state=$row['state'];
$city=$row['city'];
$descr=$row['description'];
}
else { $state=$city=null;}
if ($city and $state) {
echo "<html><head><title>$city, $state</title></head>
<body>
<h1>$city, $state</h1><p>$descr</p>
</body>
</html>
";
}
else {
echo "<html><head><title>No Entry Found</title></head>
<body>
<h1>No Entry Found</h1><p>Sorry, no entry was found. <a href="select-state.php">try again</a>.</p>
</body>
</html>
";
}
}
else { header("Location:select-state.php"); }
?>
rocknbil, if you believe that generating static pages from a database is unnecessary for what I'm trying to accomplish, could you please elaborate on your solution? I'm probably php savvy enough to implement, but not to code it from scratch.
$sql = 'SELECT columns FROM table WHERE id = "' . mysql_real_escape_string($_GET['id']) . '"';
rocknbil, if you believe that generating static pages from a database is unnecessary for what I'm trying to accomplish, could you please elaborate on your solution?
the belief that static pages are preferred by search engines.