Espero que te sirva de esta manera :
Código [Seleccionar]
function sCategorias( $sColumnas )
{
$sHTML = "";
$sSQL = "";
$sQuery = "";
# QUERY
$sSQL = "SELECT categoria, imgurl FROM categoria;";
$sQuery = sExecQuery( $sSQL );
# HTML
$sHTML .= "<table border='1'>";
$i = 1;
while( $sRows = mysql_fetch_array( $sQuery)){
if($i==1){$sHTML .= '<tr>';}
$sHTML .= "<td>".$sRows['categoria']."<br><img src='".$sRows['imgurl']."'></td>";
if($i==$sColumnas){$sHTML .= '</tr>';$i=0;}
$i++;
}//end while
$sHTML .= "</table>";
return $sHTML;
}
print sCategorias( 2 );