Hi all,
after many hours of scratching my head, it's time to turn to PHPBuilder....
Here is what i'm trying to achieve for a basic CMS:
Use $_GET to determine the current page, using the resulting variable to find the entry in the 'pages' table, get the id from that row and use to pull down the correct metadata for that page stored in 'meta' table.
Here is my code:
$pagealias = $_GET["page"];
if(isset($pagealias)){
$query = "SELECT * FROM pages WHERE alias = '$pagealias'";
$result = mysql_query($query) or die(mysql_error());
$pageid = mysql_result($result, "id") or die(mysql_error());
// echo $pageid;
$metaid = $pageid;
$query = "SELECT * FROM meta WHERE id = '$metaid'";
$result = mysql_query($query) or die(mysql_error());
$createmeta = mysql_fetch_array($result) or die(mysql_error());
echo $createmeta['metakeywords'];
echo $createmeta['metadescription'];
}
This is all working....However using "isset" is a problem because if for whatever reason 'page=' is set to a page that doesn't exist - the DB throws an error.
How can I compare all of the entries in the 'alias' column of the pages table and then if an exact match echo the meta, if not echo the websites global meta?
Hope this makes sense?
I'm thinking getting the 'alias' column into an array and then 'in_array' - I can't get this to work though....
Kind regards,
Matt