garethhall Posted May 5, 2009 Share Posted May 5, 2009 Hi I am having a slight problem and I don't understand way? Here goes I have 3 pages 1 index.php 2 /includes/header.php 3 /includes/publicAlbums.php So I need to the Album names out of the DB Now this part and the code is in publicAlbum.php Here is the code for publicAlbum.php <?php mysql_select_db($database_content, $content); // Sql query $publicAlbumSQL = "SELECT albums.albumName, clients.clientName, albums.albumDesc, albums.albumType, albums.albumDate FROM albums INNER JOIN assignElements ON albums.albumID = assignElements.albumId INNER JOIN clients ON assignElements.clientId = clients.clientID WHERE clients.clientName = 'Public'"; $recordPublicAlbum = mysql_query($publicAlbumSQL, $content) or die(mysql_error()); $rowPublicAlbum = mysql_fetch_assoc($recordPublicAlbum); ?> Now I know that the code above works as I am getting my album names out putted in the head.php page which is a include on the index.php page Here is the code for the head.php <div id="head"> <div id="menu"> <ul id="mainMenu" class="mainMenu"> <li id="home"><a href="index.php" title="Home">Home</a></li> <li id="about"><a href="about.php" title="About">About</a></li> <li id="gallery"><a href="gallery.php" title="Gallery">Gallery</a> <ul> <?php do{?> <li><a href="#" class="sub"><?php echo $rowPublicAlbum['albumName'] ?></a></li> <?php }while($rowPublicAlbum = mysql_fetch_assoc($recordPublicAlbum)) ?> </ul> </li> <li id="contact"><a href="contact.php" title="Contact">Contact</a></li> <li id="login"><a href="login.php" title="Login">Login</a></li> </ul> </div> <a href="index.php"><img src="images/logo.gif" alt="Logo" border="0" class="left"/></a> </div> So here is the problem I have the album name displaying on the header ie navigation bar but I also need to display it a second time some were else on the index.php page but I can not get it to work. Can any of you guys see what I am missing? Code for index.php page <?php require_once('Connections/content.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } //Get public albums include("includes/publicAlbums.php"); mysql_select_db($database_content, $content); $query_rs_pageDetails = "SELECT * FROM pages WHERE pageId = 1"; $rs_pageDetails = mysql_query($query_rs_pageDetails, $content) or die(mysql_error()); $row_rs_pageDetails = mysql_fetch_assoc($rs_pageDetails); $totalRows_rs_pageDetails = mysql_num_rows($rs_pageDetails); mysql_select_db($database_content, $content); $query_rs_optionalData = "SELECT optionalDataKey FROM optionalData ORDER BY optionalDataId ASC"; $rs_optionalData = mysql_query($query_rs_optionalData, $content) or die(mysql_error()); $row_rs_optionalData = mysql_fetch_assoc($rs_optionalData); $totalRows_rs_optionalData = mysql_num_rows($rs_optionalData); if($row_rs_pageDetails['pageStatus'] <> "on"){ header("Location: construction.php"); }; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="<?php echo $row_rs_pageDetails['pageMetaKeywords']; ?>" /> <meta name="description" content="<?php echo $row_rs_pageDetails['pageMetaDescription']; ?>" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $row_rs_pageDetails['pageMetaTitle']; ?></title> <link rel="shortcut icon" href="images/favicon.ico" /> <link href="css/sp.css" rel="stylesheet" type = "text/css" /> <script src="js/swfobject.js" type="text/javascript"></script> <?php do { echo $row_rs_optionalData['optionalDataKey']."\n"; } while ($row_rs_optionalData = mysql_fetch_assoc($rs_optionalData)); ?> </head> <body id="home"> <div id="container"> <!--Head and nav--> <?php include('includes/head.php');?> <!--Home Left column--> <div id="leftColumn"><?php echo $row_rs_pageDetails['pageContent']; ?> <div class="clear"></div> <h1 class="speciality">Speciality</h1> <div class="specialityPanel"> <ul class="speciality"> <?php do{?> <li><a href="gallery.php"><?php echo $rowPublicAlbum['albumName'] ?></a></li> <?php }while($rowPublicAlbum = mysql_fetch_assoc($recordPublicAlbum)) ?> <li><a href="gallery.php">Real-estate</a></li> </ul> </div> <div class="clear"></div> </div> <!--Home right flash content--> <div id="featured"> <div id="homefeatured"> </div> <script type="text/javascript"> var so = new SWFObject("featured.swf", "homefeatured" , "630", "450", "8" , "#000000" ); so.addParam("menu","false"); so.addParam("wmode","transparent"); so.write("homefeatured"); </script> </div> <!--Foot--> <?php include('includes/foot.php');?> </body> </html> <?php mysql_free_result($rs_optionalData); mysql_free_result($rs_pageDetails); ?> Quote Link to comment Share on other sites More sharing options...
farkewie Posted May 5, 2009 Share Posted May 5, 2009 Just my opinion: I reckon your better off coding the page yourself instead of letting dreamweaver do it so at least then when you want something different you know what everything is doing and you can edit it to suit. Quote Link to comment Share on other sites More sharing options...
garethhall Posted May 5, 2009 Author Share Posted May 5, 2009 Well there is only a small part that has been code with the Dreamweaver Wizard. The rest was coded by me. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 1. Is it really necessary to select the same DB three times? For reference: mysql_select_db($database_content, $content); $query_rs_pageDetails = "SELECT * FROM pages WHERE pageId = 1"; $rs_pageDetails = mysql_query($query_rs_pageDetails, $content) or die(mysql_error()); $row_rs_pageDetails = mysql_fetch_assoc($rs_pageDetails); $totalRows_rs_pageDetails = mysql_num_rows($rs_pageDetails); mysql_select_db($database_content, $content); $query_rs_optionalData = "SELECT optionalDataKey FROM optionalData ORDER BY optionalDataId ASC"; $rs_optionalData = mysql_query($query_rs_optionalData, $content) or die(mysql_error()); $row_rs_optionalData = mysql_fetch_assoc($rs_optionalData); $totalRows_rs_optionalData = mysql_num_rows($rs_optionalData); There are two there + the one in the first block of code you posted. 2. Isn't your second file named header.php? <?php include('includes/head.php');?> You don't see anything wrong with that? Quote Link to comment Share on other sites More sharing options...
garethhall Posted May 6, 2009 Author Share Posted May 6, 2009 Sorry my mistake it's called head.php Quote Link to comment Share on other sites More sharing options...
garethhall Posted May 6, 2009 Author Share Posted May 6, 2009 Ok I have carried out some more work and rewritten a lot of my code as it really needed to be streamlined However I still have the same problem. Anyone please. index.php <?php require_once('Connections/content.php'); ?> <?php mysql_select_db($database_content, $content); //Get public albums include("includes/publicAlbums.php"); include("includes/getPageDetails.php"); $pageDetailsSQL = "SELECT * FROM pages WHERE pageId = 1"; $recordPageDetails = mysql_query($pageDetailsSQL, $content) or die(mysql_error()); $rowPageDetails = mysql_fetch_assoc($recordPageDetails); //check if page is ative if($rowPageDetails['pageStatus'] <> "on"){ header("Location: construction.php"); }; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="<?php echo $rowPageDetails['pageMetaKeywords']; ?>" /> <meta name="description" content="<?php echo $rowPageDetails['pageMetaDescription']; ?>" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $rowPageDetails['pageMetaTitle']; ?></title> <link rel="shortcut icon" href="images/favicon.ico" /> <link href="css/sp.css" rel="stylesheet" type = "text/css" /> <script src="js/swfobject.js" type="text/javascript"></script> <?php do { echo $rowOptionalData['optionalDataKey']."\n"; } while ($rowOptionalData = mysql_fetch_assoc($recordOptionalData)); ?> </head> <body id="home"> <div id="container" > <!--Head and nav--> <?php include('includes/head.php');?> <!--Home Left column--> <div id="leftColumn"><?php echo $rowPageDetails['pageContent']; ?> <div class="clear"></div> <h1 class="speciality">Speciality</h1> <div class="specialityPanel"> <ul class="speciality"> <?php do{?> <li><a href="gallery.php"><?php echo $rowPublicAlbum['albumName'] ?></a></li> <?php }while($rowPublicAlbum = mysql_fetch_assoc($recordPublicAlbum)) ?> <li><a href="gallery.php">Real-estate</a></li> </ul> </div> <div class="clear"></div> </div> <!--Home right flash content--> <div id="featured"> <div id="homefeatured"> </div> <script type="text/javascript"> var so = new SWFObject("featured.swf", "homefeatured" , "630", "450", "8" , "#000000" ); so.addParam("menu","false"); so.addParam("wmode","transparent"); so.write("homefeatured"); </script> </div> <!--Foot--> <?php include('includes/foot.php');?> </div> </body> </html> head.php <div id="head"> <div id="menu"> <ul id="mainMenu" class="mainMenu"> <li id="home"><a href="index.php" title="Home">Home</a></li> <li id="about"><a href="about.php" title="About">About</a></li> <li id="gallery"><a href="gallery.php" title="Gallery">Gallery</a> <ul> <?php do{?> <li><a href="#" class="sub"><?php echo $rowPublicAlbum['albumName'] ?></a></li> <?php }while($rowPublicAlbum = mysql_fetch_assoc($recordPublicAlbum)) ?> </ul> </li> <li id="contact"><a href="contact.php" title="Contact">Contact</a></li> <li id="login"><a href="login.php" title="Login">Login</a></li> </ul> </div> <a href="index.php"><img src="images/logo.gif" alt="Logo" border="0" class="left"/></a> </div> publiclAlbums.php <?php // Sql query $publicAlbumSQL = "SELECT albums.albumName, clients.clientName, albums.albumDesc, albums.albumType, albums.albumDate FROM albums INNER JOIN assignElements ON albums.albumID = assignElements.albumId INNER JOIN clients ON assignElements.clientId = clients.clientID WHERE clients.clientName = 'Public'"; $recordPublicAlbum = mysql_query($publicAlbumSQL, $content) or die(mysql_error()); $rowPublicAlbum = mysql_fetch_assoc($recordPublicAlbum); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.