ShaneR Posted September 26, 2008 Share Posted September 26, 2008 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 More sharing options...
F1Fan Posted September 26, 2008 Share Posted September 26, 2008 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 More sharing options...
ShaneR Posted September 27, 2008 Author Share Posted September 27, 2008 Hi sorry about the code tags. Didn't work, still only displays 2 images wide. Cheers Link to comment https://forums.phpfreaks.com/topic/126001-help-with-graphic/#findComment-651632 Share on other sites More sharing options...
F1Fan Posted September 27, 2008 Share Posted September 27, 2008 Yeah, that should have worked, or at least changed something. Are you sure you saved and uploaded the file and everything? Link to comment https://forums.phpfreaks.com/topic/126001-help-with-graphic/#findComment-651646 Share on other sites More sharing options...
ShaneR Posted September 27, 2008 Author Share Posted September 27, 2008 I took out <tr valign=center> and </tr> and that fixed it. Many thanks anyway. Cheers Link to comment https://forums.phpfreaks.com/topic/126001-help-with-graphic/#findComment-651686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.