0

hello,

i have following php-mysql image list script, which populate images in columns and rows of html tables, but i want to change the html columns and rows strctures into xhtml and css, i don't know how to do,

<?php
$albumId = $_GET['album'];
$query  = "SELECT im_id, im_title, im_thumbnail
                 FROM tbl_image
	 WHERE im_album_id = $albumId
	ORDER BY im_title";
$result = mysql_query($query) or die('Error, list image failed. ' . mysql_error());
if (mysql_num_rows($result) == 0) {
	echo "No image in this album yet";
} else {
	echo '<table width="700" border="0" cellspacing="1" cellpadding="2" align="center">';

	// the image is listed in a table 
	// here we specify how many columns 
	// we want to show on each row 
	$colsPerRow = 4;
	// width of each column in percent
	$colWidth   = (int)(100/$colsPerRow);
	$i = 0;
	while ($row = mysql_fetch_assoc($result)) {
		if ($i % $colsPerRow == 0) {
			// start a new row
			echo '<tr>';
		}

		echo '<td width="' . $colWidth . '%">' . 
		     '<a href="?page=image-detail&album=' . $albumId . '&image=' . $row['im_id'] . '">' . 
		     '<img src="viewImage.php?type=glthumbnail&name=' . $row['im_thumbnail'] . '" border="0">' .
        		 '<br>' . $row['im_title'] . '</a></td>';

		if ($i % $colsPerRow == $colsPerRow - 1) {
			// start a new row
			echo '</tr>';
		}		
		
		$i += 1;
	}
	
	// print blank columns
	if ($i % $colsPerRow != 0) {
		while ($i++ % $colsPerRow != 0) {
			echo '<td width="' . $colWidth . '%">&nbsp;</td>';
		}	
		echo '</tr>';
	}	
	
	echo '</table>';

}
?>

please help in this regard....

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by MidiMagic
0

First of all, table is NOT deprecated in xhtml. There is no reason to avoid using a table where a table is needed. This sounds like tabular data.

What is discouraged is the use of tables to simulate margins and padding. This was done before styles were invented. Using tables to delineate sections of a document is also discouraged.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.