Jump to content

MySQL Meta Tags? In a bit of a rut :@


LinstefooMedia

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

 

 

Archived

This topic is now archived and is closed to further replies.

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