Jump to content

Recommended Posts

So I have been stuck on this problem for the last couple of days, and was curious if someone could lend me their brain. The end result of what I am looking to do with PHP/MySQL is this:

 

<meta name="keywords" content="<?=$ContentKeywords['keywords']['content']?>" />
<meta name="description content="<?=ContentDescription['description']['content']?>" />

 

My code looks like this:

$sql = "SELECT Id, Name, Content FROM ContentMetas";
$res = mysql_query( $sql );
$metas = mysql_fetch_assoc( $res );
return $metas;

 

So when I use this:

<meta name="keywords" content="<?=$ContentKeywords['keywords']['content']?>" />

the content remains blank  :(. How do I go about fixing this?

 

Link to comment
https://forums.phpfreaks.com/topic/51016-mysql-meta-tags-in-a-bit-of-a-rut/
Share on other sites

<?php
$sql = "SELECT Id, Name, Content FROM ContentMetas";
$res = mysql_query( $sql );
   while($keywords=mysql_fetch_object($res))
   {
       echo '<meta name="keywords" content="'.$keywords->content.'" />';
   }
?>

 

You have to use a while loop to get all the results out of the DB. Adjust the code to fit your database and such. I am not that familiar with using meta tags, so you'll need to get the variables in the right places, but that is how you would set up multiple dynamic meta tags from a database.

 

Nate

 

 

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.