Jump to content

Help with Graphic


ShaneR

Recommended Posts

Hi, the piece of code below allows me to display 2 small images side byside and then goes to the next line and displays 2 more side by side, if there are sufficient to display.

 

What I need to be able to do is display 3 images side by side, can anyone help.

 

An example can be seen at "http://www.softbizscripts.com/scripts/classifiedsplus/" on the left under premium stores, these are 2 wide I need 3 wide.

 

 

<?php

  $prm_emp_q=mysql_query("select * from sbclassified_members where premium_status='yes' and suspended='no'");

  $num_rows=mysql_num_rows($prm_emp_q);

  $max_allowed=$premium_cnt;

                       

$number[0]=-1;

if($num_rows>$max_allowed)

{

for($i=0;$i<$max_allowed;$i++)

{

$unique=0;

while($unique==0)

{

$j=rand(0,$num_rows-1);

for($k=0;$k<count($number);$k++)

{

//echo $j;

if($number[$k]==$j)

break;

}

if($k>(count($number)-1))

{

$unique=1;

}

}

$number[$i]=$j;

 

}

}// end if num > no_allowed

/*for($k=0;$k<count($number);$k++)

{

echo $number[$k]." ";

}*/

 

$row=0;

$cnt=0;

$prm_emp=mysql_fetch_array($prm_emp_q);

while (($prm_emp)&&($cnt<$max_allowed))

{

$display=0;

if($num_rows>$max_allowed)

{

for($k=0;$k<count($number);$k++)

{

if($number[$k]==$row)

{

$display=1;

}

}

}

else

{

$display=1;

}

if($display==1)

{

                       

if($cnt%2==0)

{

  ?>

          <tr valign=center>

            <?php

  }

?>

            <td width="33%"> <a href="store_info.php?id=<?php echo $prm_emp["id"];?>"><?

$img_src="default_icons/nopic.gif";

if($config["sb_default_image"]<>"")

$img_src="sbclassified_icons/".$config["sb_default_image"];

if($prm_emp["small_logo"]<>"")

$img_src="uploadedimages/".$prm_emp["small_logo"];

elseif($prm_emp["logo_url"]<>"")

$img_src="uploadedimages/".$prm_emp["logo_url"];

?><img src="<?php echo $img_src;?>"

<?php echo $imgpmt;?> alt="<? echo $prm_emp["store_title"];?>" border="1"></a>            </td>

            <?php

if($cnt%2==1)

{

  ?>

          </tr>

          <?php

}

$cnt++;

}//if display

$prm_emp=mysql_fetch_array($prm_emp_q);

$row++;

}// end while

        ?>

 

Many Thanks Shane.

Link to comment
https://forums.phpfreaks.com/topic/126001-help-with-graphic/
Share on other sites

In the future, please place your code in code tags, as it makes it easier to read.

 

I believe you can just change these two lines:

         if($cnt%2==0)
// and
         if($cnt%2==1)

to this:

         if($cnt%3==0)
// and
         if($cnt%3==1)

 

Link to comment
https://forums.phpfreaks.com/topic/126001-help-with-graphic/#findComment-651592
Share on other sites

Archived

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

×
×
  • Create New...

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.