Jump to content

Archived

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

maxic0

News content

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

Share this post


Link to post
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

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.