Jump to content

[SOLVED] I need help with displaying images!


vetman

Recommended Posts

I can display images in a table but in a coulmn only. I need help making the table of 3 columns across and 2 rows down before pagination. Here is part of my existing code in which I use Highslide and pagination. Any help would be appreciated!

Thanks in advance!

 

<?php


// store the record of the "gold" table into $row

$current = '';


// keeps getting the next row until there are no more to get

while($row = mysql_fetch_array( $result ))
	 {
$id = $row['id'];
if (!$current) {
echo "<center><table>";
$current = $id;
} elseif ($current != $id){
echo "</table><br><br><table>";
$current = $id;
}
// Print out the contents of each row into a table
echo '<tr>
                           <td><div><a id="thumb1" href="'.$row['image'].'" class="highslide" onclick="return hs.expand(this)">
	<img src="'.$row['image_th'].'" title="Click to enlarge" /></a>

<div class="highslide-caption">'.$row['caption'].'
</div></td>';

}
        echo "</table>";
        echo "<br>";
        
?>

Untested but try this

<?php
// store the record of the "gold" table into $row

$current = '';


// keeps getting the next row until there are no more to get
$SetRows = 3;
$RowCount = 0;
while($row = mysql_fetch_array( $result ))
{
	$id = $row['id'];
	if (!$current) {
		echo "<center><table>";
		$current = $id;
	} elseif ($current != $id){
		echo "</table><br><br><table>";
		$current = $id;
	}
	echo ($RowCount==0)?'<tr>':'';
	echo '<td><div><a id="thumb1" href="'.$row['image'].'" class="highslide" onclick="return hs.expand(this)"><img src="'.$row['image_th'].'" title="Click to enlarge" /></a><div class="highslide-caption">'.$row['caption'].'</div></td>';
	echo ($RowCount==$SetRows)?'</tr>':'';
	$RowCount = ($RowCount==0)?$SetRows)?:$RowCount--;
}
echo ($RowCount!=$SetRows)?'</tr>':'';
        echo "</table>";
        echo "<br>";
        
?>

Opps, revised, i didn't notice the creation of the table in the loop

 

try this

<?php
// store the record of the "gold" table into $row

$current = '';

// keeps getting the next row until there are no more to get
$SetRows = 3;
$RowCount = 0;
echo "<center><table>\n";
while($row = mysql_fetch_array( $result ))
{
	$id = $row['id'];
	echo ($RowCount==0)?'<tr>':'';
	echo '<td><div><a id="thumb1" href="'.$row['image'].'" class="highslide" onclick="return hs.expand(this)"><img src="'.$row['image_th'].'" title="Click to enlarge" /></a><div class="highslide-caption">'.$row['caption'].'</div></td>'."\n";
	echo ($RowCount==$SetRows)?"</tr>\n":'';
	$RowCount = ($RowCount==0)?$SetRows:$RowCount-1;
}
echo ($RowCount!=$SetRows)?"</tr>\n":"";
    echo "</table></center>";
    echo "<br>";
        
?>

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.