So I'm building this website; the first I've tried to build using a mostly dynamic
structure. What I've done is create a mysql table, with two fields: id and page_val.
The idea is you call the page like http://www.someplace.com/page.php?id=404 and it'll
spit back (in this case) the infamous 404 not found page. I've got it so it'll spit
back stuff from the DB, but only if I hard-code it...which defies the whole point of
this exercise.
Here's what I've got thus far:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Welcome to boardlady.com!</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<SCRIPT language="JavaScript1.2" src="main.js"type="text/javascript"></SCRIPT>
</head>
<body>
<DIV id="TipLayer"
style="visibility:hidden;position:absolute;z-index:1000;top:-100"></DIV>
<SCRIPT language="JavaScript1.2" src="style.js" type="text/javascript"></SCRIPT>
<table width=750>
<tr><td>
<table>
<tr><td><img src="banner-1.gif" alt="The Board Lady - Eva-M. Hollmann"></td><td>Over
<b>3,281</b> Served!</td></tr>
</table>
<table><tr><td class="sidebox"><a href="index.html"
onMouseOver="stm(Text[00],Style[12])" onMouseOut="htm()">HOME</a><br><br><br><a
href="intro.html" onMouseOver="stm(Text[01],Style[12])"
onMouseOut="htm()">INTRO</a><br><br><br><a href="repairs.html"
onMouseOver="stm(Text[02],Style[12])" onMouseOut="htm()">REPAIRS</a><br><br><br><a
href="prices.html" onMouseOver="stm(Text[03],Style[12])"
onMouseOut="htm()">PRICES</a><br><br><br><a href="faq.html"
onMouseOver="stm(Text[04],Style[12])" onMouseOut="htm()">FAQ</a><br><br><br><a
href="trailer.html" onMouseOver="stm(Text[05],Style[12])"
onMouseOut="htm()">TRAILER</a><br><br><br><a href="contact.html"
onMouseOver="stm(Text[06],Style[12])" onMouseOut="htm()">CONTACT ME</a><br><br><br><a
href="directions.html" onMouseOver="stm(Text[07],Style[12])"
onMouseOut="htm()">DIRECTIONS</a></td>
<td valign="top">
<!--Begin main body text-->
<?php
define ('DB_USER', 'user');
define ('DB_PASSWORD', '********');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'database');
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to
database: ' . mysql_error());
@mysql_select_db (DB_NAME) OR die ('Could not connect to database: ' . mysql_error());
if ($page_req == "") {$id="index";}
elseif ($page_req == "index") {$id="index";}
else { $id="404";}
$query = "SELECT page_val FROM boardlady_site WHERE id =404";
$result = @mysql_query ($query);
while ($row = mysql_fetch_array($result)) {echo $row[0];}
mysql_close();
?>
<!--End main body text-->
</td>
</tr>
<tr><td colspan=2><center><div class="footer" onMouseOver="stm(Text[08],Style[12])"
onMouseOut="htm()">This site <a href="copyright.html" style="color:#2f2f2f;
font-size:xx-small;text-decoration:none;font-weight:bold;" target="new">copyright
(C)</a> 2004 by Eva-M. Hollmann. All rights reserved.</div><div
class="footer"><br>Website design by Dan at <a href="http://www.dibcomputers.com"
style="color:#2f2f2f; font-size:xx-small;text-decoration:none;font-weight:bold;"
target="new">DIB Computers.</a></div></center></td></tr></table>
</td></tr></table>
</body>
</html>
First off, I need to know how to fetch variables out of the URL. I know this is
/supposed/ to be easy...but dammit I just can't get it to work. The other part that's
pissing me off is trying to stuff a variable inside my query variable...no matter what
I try I get a syntax error.
Yeah, I'm that noob. So were we all.
Thanks in advance,
Dan