LinstefooMedia Posted May 12, 2007 Share Posted May 12, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/51016-mysql-meta-tags-in-a-bit-of-a-rut/ Share on other sites More sharing options...
chronister Posted May 12, 2007 Share Posted May 12, 2007 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/51016-mysql-meta-tags-in-a-bit-of-a-rut/#findComment-251119 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.