Jump to content

Include Keywods Description And Title For Each Page Differently


slayboy

Recommended Posts

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>

Link to comment
Share on other sites

: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.

Link to comment
Share on other sites

<?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>

Link to comment
Share on other sites

<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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.