do while conditions


Posted on 16th Feb 2014 07:03 pm by admin

i want to display 6 images in a 2x3 table
now what would be the correct logic to
count that there are 6 images results
and if there are more than 6 images loop and echo the rest but not in the table
but as links?

the idea is to have 6 thumbnails and then a large images in a gallery

this is what i played with it gives me the table i want , how should i add the additional condition - echo the remaining inages after the 6th??

Code: <table>
<tr>
<?php
$RsImage_list_endRow = 0;
$RsImage_list_columns = 2; // number of columns
$RsImage_list_hloopRow1 = 0; // first row flag
do {
if($RsImage_list_endRow == 0 && $RsImage_list_hloopRow1++ != 0) echo "<tr>";
?>
<td width="85"><a href="/images/<?php echo $row_RsImage_list['imagename']; ?>" rel="lightbox[<?php echo $row_RsImage_list['ProductID']; ?>]"><img src="<?php echo $row_RsImage_list['imagename']; ?>" width="85" height="64" border="0"/></a></td>
<?php $RsImage_list_endRow++;
if($RsImage_list_endRow >= $RsImage_list_columns) {
?>
</tr>
<?php
$RsImage_list_endRow = 0;
}
} while ($row_RsImage_list = mysql_fetch_assoc($RsImage_list));
if($RsImage_list_endRow != 0) {
while ($RsImage_list_endRow < $RsImage_list_columns) {
echo("<td>&nbsp;</td>");
$RsImage_list_endRow++;
}
echo("</tr>");
}?>
</table>

No comments posted yet

Your Answer:

Login to answer
111 Like 48 Dislike
Previous forums Next forums
Other forums

PHP If Else statement for breadcrumb
Hi

I am trying to use a PHP if else statement to display a breadcrumb link on wordpress

Converting from one format to another
"I have got a date in DD/MM/YYYY but I need it in MM-DD-YYYY. Help!"

noob cURL help
I have a pretty basic form that I need to cURL post to a file in my includes folder (includes/login.

PHP mail() returns true but doesn't work
First off I apologize if this is a newbie question, and I generally don't like asking questions that

Displaying Multidimensional Arrays...about to put my head in a vice, PLEASE HELP
I am fairly new to PHP and MySQL and I have a problem which I have been trying to resolve for days.

weird problem
last time, i did post a topic concerning why my page sometime will load as blank page when using IE.

some query on multilingual website
Hi all,

Which is the simplest and easiest method to make a website multilingual,
is it put

Optimize Code
Just started getting into the use of cookies. The following code will redirect users to a set URL s

Help with writing "$" with fopen
I just can't get my syntax correct. Could someone help me please? I am trying to write a connect fil

PHP - HTTP Digest Authentication - Understanding Code Help
Hi Everyone,

This is my first time on your website and please excuse if I am asking silly que

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash