slayboy Posted October 4, 2012 Share Posted October 4, 2012 my question now is everything is working like my template and the content all i want is to include keywods description and title for each page different it is giving me headache i have a database name pages it has 6 columns id,name,title,description,keywords ,status.where name=home,about,contact etc <?php // Set document: include ('config/setup.php'); if(!isset($_GET['page'])) { $pg= 'page'; }else{ $pg= $_GET['page']; } ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>help</title> <meta name="description" content="." /> <meta name="keywords" content=" " /> </head> <body> <!-- Header Start --> <div id="logo"> <a class="logo" =pic"> <div class="right"> <?php include('template/right_logo.php');?> </div> </div> <div id="header"> <?php include('template/header.php');?> </div> <!-- Header End --> <!-- Main Start --> <div id="main"> <!-- ### Main Left Start ### --> <div id="left"> <?php //include('content/'.$pg.'.php'); $q="SELECT*FROM pages WHERE name='$pg' "; $r=mysqli_query($dbc,$q); $page= mysqli_fetch_assoc($r); echo '<div class="content_body">'.$page['body'].'</div>'; ?> </div> <!-- ### Main Left End ### --> <!-- ### Main Rigt Start ### --> <div id="right"> <?php include('template/right.php');?> </div> <!-- ### Main Rigt End ### --> <div class="clear"></div> <div id="footer"> <?php include('template/footer.php');?> </div> </div> </div> <!-- Main End --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/ Share on other sites More sharing options...
ManiacDan Posted October 4, 2012 Share Posted October 4, 2012 Once again, welcome to a forum. I asked you questions in your cross-post to devshed. Please answer them, and format your code. Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1382722 Share on other sites More sharing options...
White_Lily Posted October 5, 2012 Share Posted October 5, 2012 (edited) Please re-post your code in the [ code][/ code] tags, makes things so much easier. Edited October 5, 2012 by White_Lily Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1382860 Share on other sites More sharing options...
slayboy Posted October 5, 2012 Author Share Posted October 5, 2012 sorry guys that code is upsetting i reposted again sorry again here is the link http://forums.phpfreaks.com/topic/269134-include-keywods-description-and-title-for-each-page-different/ Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383043 Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 :eyeroll: and I just removed that thread for being a duplicate. Just post the code HERE. In code tags. All you need to do is move your query to before the point where you intend to use values you get FROM the query. Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383046 Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2012 Share Posted October 5, 2012 AND post all the code for ONE file in ONE set of [ code ] [ /code ] tags. Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383052 Share on other sites More sharing options...
slayboy Posted October 5, 2012 Author Share Posted October 5, 2012 <?php // Set document: include ('config/setup.php'); if(!isset($_GET['page'])) { $pg= 'page'; }else{ $pg= $_GET['page']; } ?> <!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> <title>help</title> <meta name="description" content="." /> <meta name="keywords" content=" " /> </head> <body> <!-- Header Start --> <div id="logo"> <a class="logo" href="index.php?page=home"> <img src="images/logo/BESTLOGO.png" border="0" alt="BESTSOM"></a> <div class="right"> <?php include('template/right_logo.php');?> </div> </div> <div id="header"> <?php include('template/header.php');?> </div> <!-- Header End --> <!-- Main Start --> <div id="main"> <!-- ### Main Left Start ### --> <div id="left"> <?php //include('content/'.$pg.'.php'); $q="SELECT*FROM pages WHERE name='$pg' "; $r=mysqli_query($dbc,$q); $page= mysqli_fetch_assoc($r); echo '<div class="content_body">'.$page['body'].'</div>'; ?> </div> <!-- ### Main Left End ### --> <!-- ### Main Rigt Start ### --> <div id="right"> <?php include('template/right.php');?> </div> <!-- ### Main Rigt End ### --> <div class="clear"></div> <div id="footer"> <?php include('template/footer.php');?> </div> </div> </div> <!-- Main End --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383059 Share on other sites More sharing options...
slayboy Posted October 5, 2012 Author Share Posted October 5, 2012 how about now i like this forum its active thanks i need help now please Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383060 Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 <head> <title>help</title> <meta name="description" content="." /> <meta name="keywords" content=" " /> </head> Take that, and make it: <?php $q="SELECT * FROM pages WHERE name='$pg'"; $r=mysqli_query($dbc,$q); $page= mysqli_fetch_assoc($r); echo '<div class="content_body">'.$page['body'].'</div>'; ?> <head> <title><?php echo $page['title']; ?></title> <meta name="description" content="<?php echo $page['description']; ?>" /> <meta name="keywords" content=" " /> </head> Assuming of course that your column names are "title" and "description." You said they existed but nor what they are. Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383063 Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 All you need to do is move your query to before the point where you intend to use values you get FROM the query. Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383064 Share on other sites More sharing options...
slayboy Posted October 5, 2012 Author Share Posted October 5, 2012 maniac it is not working thanks for the reply the title is becoming the url of the site can you try to give me a simple script that will help me to get the page title ,descriptions and keywords one for a dynamic website thats all need any script you can think of any one thnks Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383078 Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 no because I don't have access to your database the code I provided was easy to understand since it matches your code nearly line for line it included two variables which should match your database columns which you previously said existed if they don't match what you said figure out what the real column names are and replace them that's all we can tell you with the small amount on information you have given us if you keep doing nothing but pasting your code over and over we can't help you if there's something else you can tell us then tell us (capitalization and punctuation removed to match OP's style) Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383081 Share on other sites More sharing options...
slayboy Posted October 5, 2012 Author Share Posted October 5, 2012 This is how my database is CREATE TABLE `pages` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR( 255 ) NOT NULL , `content` TEXT NOT NULL , `created_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `status` TINYINT NOT NULL DEFAULT '1', `created_by` VARCHAR( 255 ) NOT NULL , `modified_by` VARCHAR( 255 ) NOT NULL , `modified_date` DATETIME NOT NULL , `meta_keywords` TEXT NOT NULL , `meta_description` TEXT NOT NULL ) just understand am new to this programming do understand how impoartant is a beginner like me and others reading this Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383083 Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 Am I invisible again? Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383100 Share on other sites More sharing options...
slayboy Posted October 5, 2012 Author Share Posted October 5, 2012 guru you are not i tried it just that i didnt get what you said am not understanding am sory i dont mean to ignore you Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383101 Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 What don't you understand? Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383102 Share on other sites More sharing options...
ManiacDan Posted October 6, 2012 Share Posted October 6, 2012 My code uses 'title' and 'description', since you told me those were the variable names. Your actual variables are 'title' and 'meta_description'. Change the one, and it should work. If not, there isn't much we can do for you. You need to start debugging this yourself. Echo the query. Is it right? Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383134 Share on other sites More sharing options...
slayboy Posted October 6, 2012 Author Share Posted October 6, 2012 it is not working will find a way out and try my best. thanks all who tried to help me Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383332 Share on other sites More sharing options...
ManiacDan Posted October 7, 2012 Share Posted October 7, 2012 Not sure why we keep having to do this: Echo the query. Is it right? Quote Link to comment https://forums.phpfreaks.com/topic/269081-include-keywods-description-and-title-for-each-page-differently/#findComment-1383409 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.