Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-24-2012, 04:48 PM   PM User | #1
jake_grant
New Coder

 
Join Date: Jan 2011
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
jake_grant is an unknown quantity at this point
Add a new box for every news article

On my site, I am trying to make the code below add a new box for each news article in the database.
So far i have only managed to get it to output the first article in a box before it puts all the articles inside the first articles's box rather than a box of their own. (If that was a bit hard to understand, i have put 2 images to show how i need it to work)

Currently it does this:


I need it to do this


the code i have so far is.
PHP Code:
<?php
                $query 
mysql_query('SELECT * FROM news ORDER BY id DESC LIMIT 1');
                while(
$output mysql_fetch_assoc($query))
                {
                
?>
                <div class="bs-docs-example">
                  <div class="accordion" id="accordion2">
                    <div class="accordion-group">
                      <div class="accordion-heading">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#<?php echo $output['id']; ?>">
                        <?php
                        
echo $output['subject'].'<br />';
                        
?>
                        </a>
                      </div>
                      <div id="<?php echo $output['id']; ?>" class="accordion-body collapse">
                           <?php 
                           
echo '<div class="accordion-inner">';
                           echo 
$output['news'].'<br / >'?>
                           <br>
                          <br><blockquote class="pull-right"><?php
                          
echo 'Posted by '.$output['postedby']; 
                          
?>
                          </blockquote>
                          <?php ?>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
jake_grant is offline   Reply With Quote
Old 12-24-2012, 07:18 PM   PM User | #2
jake_grant
New Coder

 
Join Date: Jan 2011
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
jake_grant is an unknown quantity at this point
Anyone able to help?
jake_grant is offline   Reply With Quote
Old 12-24-2012, 07:41 PM   PM User | #3
Custard7A
Regular Coder

 
Custard7A's Avatar
 
Join Date: Jul 2010
Location: Australia
Posts: 269
Thanks: 32
Thanked 32 Times in 32 Posts
Custard7A is an unknown quantity at this point
Uh, because you are closing your while loop before all the divs are ended?
Custard7A is offline   Reply With Quote
Users who have thanked Custard7A for this post:
jake_grant (12-24-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:43 PM.


Advertisement
Log in to turn off these ads.