coverting html tables into xhtml and css

Reply

Join Date: May 2008
Posts: 74
Reputation: servis is an unknown quantity at this point 
Solved Threads: 0
servis servis is offline Offline
Junior Poster in Training

coverting html tables into xhtml and css

 
0
  #1
Oct 15th, 2008
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....
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: coverting html tables into xhtml and css

 
0
  #2
Oct 15th, 2008
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.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC