Jump to content

News content


maxic0

Recommended Posts

Hi, i have another question.. Sorry.

Well on my site i have news content, and when i want it to appear in its box i have to put..

[code]<div id="header"></div>
<div id="content">
<p>Content here!</p>
</div>
<div id="footer"></div>[/code]

...But my information is stored in a database.

Can someone please tell me how i would select each piece of info and put it inside the above, so each news content is in a seperate box?

Thanks

Link to comment
Share on other sites

making some assumptions about fields...

[code]
<?PHP

#... db connection stuff, query your database table, ... somthing like "SELECT header, content, footer FROM ..."
#... put results in array $results

foreach ($results as $news_item)
{
  ?>
  <div id="header"><?= $news_item['header'] ?></div>
  <div id="content">
      <h4>... other content stuff ...</h4>
      <?= $news_item['content'] ?>
  </div>
  <div id="footer"><?= $news_item['footer'] ?></div>
<?PHP
}
?>
[/code]

I'm not sure if this is what your after, but hth.

Jeff
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.