Page 1 of 1

PHP.. I need Help with a Simple Loop..

Posted: Thu Jul 16, 2009 7:43 pm
by GenZod
Ok, I don't really know PHP, but I've been able to find Code Snippets for everything up to this point..

Now I need a pretty advanced loop for my Blog..

So basically, Imagine if you will.. on my wordpress Blog, I have 1 column on the left.. If this column gets filled with more than 10 posts, then I want it to go to the next div column on the right.. SO there are 2 columns.. I already have the columnleft and column right classes built.. I just odn't know the code to let it know if there are more than 10 posts.. go to the next area.... here is the code on the page..

Code: Select all

<div id="contentleft">  
 
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 
    <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    <?php the_content(__('Read more'));?>
 
    <div class="bt-links"><span class="highlight">Genre:</span> <?php the_category(' | ') ?></div>
 
    <br />
 
    <img src="/images/img-postSpacer.gif" />
 
    
    <?php endwhile; else: ?>
 
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
    <?php posts_nav_link(' &#8212; ', __('&laquo; go back'), __('keep looking &raquo;')); ?>
 
</div>
 
 
...

Please help me add the contentright and loop after 10 into this.. Thanks!

Re: PHP.. I need Help with a Simple Loop..

Posted: Fri Jul 17, 2009 3:54 am
by chathuranga
first get the total count, and then loop until you want and then pass the reminder to other div or page.

you can use mysql_num_rows() to get count of the records. or if you using an array then sizeof() can be use.

i think what you want is a pagination.

Re: PHP.. I need Help with a Simple Loop..

Posted: Fri Jul 17, 2009 8:33 am
by GenZod
Can you give me some example code from what you just said? I know pretty much nothing about PHP.. I'm just trying to piece together tid bits..