Jump to content

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>";
        
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.