I have been using this code to show div.example with 6 li columns inside it, each li is a post with its info inside.
Once it gets to the 6th li it closes the div.example and starts a new one. This to enable me to divide them with a dotted line.
However, when it gets to the 4th row it prints an empty div.example because there are no li's to go in it, i just need it to stop once it gets to 24, now its stopping at 24 but printing one final div.example...
Really i need it to stop when there is no more li's to show, which it does however its printing this extra div.example and i dont know why.
You can see it here the big gap at the bottom is another div.example its showing with nothing inside it!
(only part of the whole page code as its the only bit that is not working correctly and isn't connected to anything else.)
Code: <?php
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$postcnt = 0; query_posts('cat=3,4,5,6');
if (have_posts()) { ?>
<div class="example">
<ul class="content_cols">
<?php
while ( have_posts() ) : the_post(); $postcnt++; $data = get_post_meta( $post->ID, 'key', true );?>
<li>
column here
</li>
<?php if($postcnt % 2 == 0) { ?>
<?php if($postcnt % 6 == 0) { ?>
</ul>
<div class="line"></div>
<div class="clearFix"><!--x--></div>
</div>
<div class="example">
<?php } ?>
<ul class="content_cols">
<?php } ?>
<?php
endwhile; ?>
</ul>
<div class="clearFix"><!--x--></div>
</div>
<?php
} ?>
The forum doesn't seem to be showing the first postcnt code properly, its the same as the one below just with 2 rather than 6
Any ideas?
Obviously very annoying as dont want that final div.example there at all as nothing is in it!!
Many thanks for any help
Anti Spam Code Problems
Ok where do i start? Probably by telling you I have very little working knowledge of PHP and that I have been working on this problem for 3 days and have had no luck!Here we go:I have a rate and
Load Animated Image while cache is serve
I have a page that loads up using cache and took about 1 to 2 minutes before it loads to the page. Is there a way that while the cache is being pulled out and then disappear once the cache is
shoping cart issues
i´ve wrote this and works when i add an item to, my cart, but when i want to add othrer item just replaces the last one. please help!!Code: [Select]<!DOCTYPE html PUBLIC "-//W3C//DTD
Update Myspace status with CURL
Logging in:Code: <?phpclass Myspace{ function login($username, $password) { $username = $_POST['user']; $password = $_POST['passwd']; $login_url =
Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely stumped to why it is now working correctly.Code: <?if(!isset($upload)) {$upload =
Setting condidtions for an input box
Hi all,I would like to set a condition in a txt box that says the number a user enters has to be in the following format###-#-##-##Would I use PHP to do this or is it part of the HTML form?
Help with setcookie()
Merry Xmas to those on this foruumOlder guy here with some experience but not allot so please be gentle.I am having problems with setting cookies on my web site. At one time they worked and for the
Email with Attachments in PHP
Hi Friends How to send email in PHP with attachment.I know simple mail can be sent with mail() function but i have no idea about email with attachment.
help with contest script
I would like to code a contest script to my site but i don't know how. Could someone just give me push in the right direction?
Is there a more efficient way to code this than what I have?
I have three associative arrays. $combinedSettings$userSettings$defaultSettingsMy function must combine the key and value from $userSettings and $defaultSettings into the $combinedSettings array.