Jump to content

Archived

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

maxic0

News content Help

Recommended Posts

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]
<?php
include "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>
<?php
echo "<BR />";
}
echo "</DIV>";
?>
[/code]

Im really stuck :-[

Please someone help me!

Thanks
Max

Share this post


Link to post
Share on other sites
[code]
<?php
include "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>
<?php
echo "<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.

Share this post


Link to post
Share on other sites

×

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.