<?php
include "conn.php";

$query = "select mediaName, mediaDescrip, mediaURL, mediaID from media_media order by mediaName asc";

$result = mysql_query($query) or die (mysql_error());


echo "<table border=0 width=100% cellpadding=5 cellspacing=0>";

$iCounter = 0;

while ($row = mysql_fetch_array($result))
{
	$mediaName = $row[0];
	$mediaDescrip = $row[1];
	$mediaURL = $row[2];
	$mediaID = $row[3];
	
	$len = strlen($mediaDescrip);
	
	
	if ($iCounter == 0)
	{
		echo "<tr>";
	}

	echo "<td width=33% align=center height=100%>";
	echo "<table width=100% height=100% border=0 cellspacing=0 cellpadding=3><tr><td align=\"center\" valign=\"top\"><a href=\"javascript:openPopWin('pd.php?id=$mediaID', 550,500)\"><img src=\"press/$mediaURL\" width=150></a></td></tr><tr><td align=\"center\" valign=\"bottom\"><font face=verdana size=2>$mediaName</font></td></tr></table>";
	echo "</td>";

	if ($iCounter == 2)
	{
		echo "</tr>";
	}

	$iCounter = ($iCounter + 1) % 3;
}

if ($iCounter == 1) // 2 more
{
	echo "<td></td><td></td></tr>";
}
elseif($iCounter == 2) // 1 more
{
	echo "<td></td></tr>";
}
echo "</table>";
?>