Jump to content

pagination and word wrap(sort of thing) on tables??


Recommended Posts

with this code i need to have pagination for it, and i need it so only 3 images a row on the page.

so like ,

|image1|image2|image3|

instead of

image1

image2

image3

 

this is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Hayley - Home</title>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
</head>
<body>
<div id="body"> 
<?php
if (isset($_GET['image_id']))
{
if ((int) $_GET['image_id'] > 0) 
{

$imageid = $_GET['image_id'];
$sql = "SELECT * FROM hayleyimages WHERE image_id=$imageid";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$imageprofname = $row['image_name'];
$imageprofcaption = $row['image_caption'];
$imageproflink = $row['image_link'];
if(mysql_num_rows($result) > 0)
{
?>
	<table align="center" border="1"><th><?php echo "$imageprofname"; ?></th>
<tr><td><?php echo '<a href="'.$row['image_link'].'" rel="lightbox" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$row['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$row['image_caption']. ' </a>'; ?></td></tr></table>
<?php
}
	if (mysql_num_rows($result) < 1) {
		 echo 'This ID does not exist in the database<br>';
		 echo "<a href=\"index.php\">Return to Image Page</a>";
		 exit();
	}
exit();
}
	else {
	 echo "Unknown Image ID! <br />";
	 echo "<a href=\"index.php\">Return to Image Page</a>";
	 exit();
	}
}
//No ID passed to page, display user list:
$query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`";
$result = mysql_query($query) or die("Error:" . mysql_error());

if (mysql_num_rows($result) > 0) {
	while($row=mysql_fetch_array($result)){ // Start looping table row
	?>
	<table border="1"><th>Images</th>
	<tr><td><?php echo ' <a href="?image_id='.$row['image_id'].'">'.$row['image_name']. ' Details</a>'; ?></td><td><?php echo ' <a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" >'.$row['image_name']. ' </a>'; ?></td><td><?php echo ' <img src="'.$row['image_link'].'"width="200px" /></a>'; ?><br /></td></tr>
	</table>
	<?php
	}
		if (mysql_num_rows($result) < 1) {
		echo "No Images To Display";
		}
}
mysql_close();
?>
</div>
</body>
</html>

Link to comment
Share on other sites

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.