maxic0 Posted September 12, 2006 Share Posted September 12, 2006 Hi, im creating a page and i want the content to display in boxes on my home page.I have set up the CSS, and it works fine when i type i the content myself, but when i get the content from my database i have a little probelm.For testing i created a new content that says "Blah Blah".Then i looked on my homepage to see if it was displayed..But instead of it displaying a content box that contains "Blah Blah".I have two content boxes that both contain "B". Here is my code..[code]<?phpinclude "connect.php";echo "<DIV ALIGN='center'>";$result = mysql_fetch_array(mysql_query("SELECT content FROM content"));foreach ($result as $news_item){ ?> <div id="header"></div> <div id="content"> <p> <?php echo $news_item['content']; ?> </p> </div> <div id="footer"></div><?phpecho "<BR />";}echo "</DIV>";?>[/code] Im really stuck :-[Please someone help me!ThanksMax Quote Link to comment https://forums.phpfreaks.com/topic/20528-news-content-help/ Share on other sites More sharing options...
ober Posted September 12, 2006 Share Posted September 12, 2006 [code]<?phpinclude "connect.php";echo "<DIV ALIGN='center'>";$result = mysql_query("SELECT content FROM content") or die(mysql_error());while($row = mysql_fetch_array($result)){ ?> <div id="header"></div> <div id="content"> <p> <?php echo $row['content']; ?> </p> </div> <div id="footer"></div><?phpecho "<BR />";}echo "</DIV>";?>[/code]Try that. You really shouldn't combine all your functions like that. It makes it a nightmare to troubleshoot. Also, this is not where you want to use a foreach. Quote Link to comment https://forums.phpfreaks.com/topic/20528-news-content-help/#findComment-90561 Share on other sites More sharing options...
maxic0 Posted September 12, 2006 Author Share Posted September 12, 2006 Yay it works! Thanks man. Quote Link to comment https://forums.phpfreaks.com/topic/20528-news-content-help/#findComment-90567 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.