Jump to content

News content Help


maxic0

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
Link to comment
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.
Link to comment
Share on other sites

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.