vetman Posted June 19, 2008 Share Posted June 19, 2008 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/ Share on other sites More sharing options...
MadTechie Posted June 19, 2008 Share Posted June 19, 2008 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-568999 Share on other sites More sharing options...
vetman Posted June 19, 2008 Author Share Posted June 19, 2008 I'm getting an error: Parse error: parse error, unexpected ')' Because I added it to my code, I can't tell the line number. Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-569012 Share on other sites More sharing options...
vetman Posted June 19, 2008 Author Share Posted June 19, 2008 Anyone! Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-569652 Share on other sites More sharing options...
hitman6003 Posted June 19, 2008 Share Posted June 19, 2008 Pretty sure it has to do with this line: $RowCount = ($RowCount==0)?$SetRows)?:$RowCount--; Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-569661 Share on other sites More sharing options...
vetman Posted June 19, 2008 Author Share Posted June 19, 2008 That's the line I thought it was also. I tried several combinations but to no avail. Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-569685 Share on other sites More sharing options...
hitman6003 Posted June 19, 2008 Share Posted June 19, 2008 Without really checking to see what your code is trying to do, try this: $RowCount = ($RowCount == 0 ? $SetRows : $RowCount--); Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-569687 Share on other sites More sharing options...
vetman Posted June 19, 2008 Author Share Posted June 19, 2008 Well, the error went away, but the page didn't change, it came up as it has always done. What I'm trying to do is post 3 picture across the screen in 2 different rows for a total of six pictures per page. Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-569697 Share on other sites More sharing options...
MadTechie Posted June 20, 2008 Share Posted June 20, 2008 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-570184 Share on other sites More sharing options...
vetman Posted June 20, 2008 Author Share Posted June 20, 2008 Thanks, I really appreciate you help! Works fine now! I just couldn't figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/110910-solved-i-need-help-with-displaying-images/#findComment-570239 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.