Jump to content

data output help ....


imarockstar

Recommended Posts

 

hey I have this code that displays images ... but it just spits them out ... Is there away to where i can limit the amount of images displayed on each row ... like i need to have it out output :

 

"<br class='clear'>"

 

after a certain number of images .. say 10 ..

 

this is my code :

 

 

<?php

$image_path = 'flyers/';

// Retrieve data from database 
$sql="SELECT * FROM flyers WHERE uid = ". $_SESSION['id'];
$result=mysql_query($sql);

// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>

<div class='flyerbox'>
<a href="viewimage.php?maxsize=640&source=<?=$image_path.$rows['flyer'] ?>" rel="facebox">
<img src="viewimage.php?maxsize=75&source=<?=$image_path.$rows['flyer'] ?>" /></a> <br>
remove
</div>			


<? } ?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/160827-data-output-help/
Share on other sites

Try this - it probably isn't the best way to do it, but it should work.

 

<?php
$image_path = 'flyers/';

// Retrieve data from database 
$sql = "SELECT * 
  FROM flyers 
  WHERE uid = " . $_SESSION['id'];

$result = mysql_query($sql);

// Initialise count
$i = 0;

// Start looping rows in mysql database.
while($rows = mysql_fetch_array($result)){
?>
<div class="flyerbox" style="float:left;">
	<a href="viewimage.php?maxsize=640&source=<?=$image_path.$rows['flyer'] ?>" rel="facebox">
	<img src="viewimage.php?maxsize=75&source=<?=$image_path.$rows['flyer'] ?>" /></a>
</div>         

<?php
if ($i <= 9) { # if count is 9 or less increment count by 1 and loop
	$i++;
} else {# if count is 10 add 'break' and reset counter
 	$i = 0;
	 ?>
	<div style="clear:both;"></div>
<?php
}
}

Link to comment
https://forums.phpfreaks.com/topic/160827-data-output-help/#findComment-848840
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.