Jeg har nemlige lavet noget på den måde du vil have det som...
[snip]
<table width="100%" class="mainTable">
<tr align="left" valign="top">
<?php
// Fetch all categories associated with user
$category =
$__DATABASE->get('SELECT usr.usr_username AS user, cat.cat_name AS category, cat.cat_id AS cat_id, COUNT(cat.cat_id) as links_in_cat
FROM category AS cat
LEFT JOIN users AS usr ON cat.cat_user = usr.usr_id
LEFT JOIN links ON cat.cat_id = links.link_cat
WHERE usr.usr_id = '.$_SESSION['user']['id'].'
GROUP BY cat.cat_id
ORDER BY cat.cat_name');
// Continue if we got some data out
if ( is_array($category) ) {
// Run through all the categories
$left_tabel = '<td width="50%"><table border="0" class="mainTable">';
$right_tabel = '<td width="50%"><table border="0" class="mainTable">';
for ($idx = 0; $idx < count($category); $idx++) {
// Extend left table with categori
$left_tabel .= '
<tr>
<td><b>'.stripslashes($category[$idx]['category']).'</b></td>
</tr>';
// Fetch all the links to each categori
$links =
$__DATABASE->get('SELECT links.link_name as name, links.link_ref as ref, links.link_hits as hits, links.link_id as link_id
FROM category as cat LEFT JOIN links ON cat.cat_id = links.link_cat
WHERE links.link_cat = '.$category[$idx]['cat_id'].'
ORDER BY links.link_name');
// Continue if there is any links in the category
if ( is_array($links) ) {
// Run through all the links in the category
foreach ($links as $link) {
$left_tabel .= '
<tr>
<td><a href="handler.php?cmd=link&id='.$link['link_id'].'" onmouseover="setStatus(\'
http://'.$link['ref'].'\'); return true;" onmouseout="setStatus(\'\'); return true;">'.$link['name'].'</a> - ['.$link['hits'].' hits]</td>
</tr>';
}
}
else {
$left_tabel .= '
<tr>
<td>Der er ikke oprettet nogen links i denne kategori endnu</td>
</tr>';
}
$left_tabel .='
<tr>
<td><br /></td>
</tr>';
// Check to see if there is enough categories for another right table category
if ( ++$idx < count($category) ) {
$right_tabel .= '
<tr>
<td><b>'.stripslashes($category[$idx]['category']).'</b></td>
</tr>';
// Fetch all the links to each categori
$links =
$__DATABASE->get('SELECT links.link_name as name, links.link_ref as ref, links.link_hits as hits, links.link_id as link_id
FROM category as cat LEFT JOIN links ON cat.cat_id = links.link_cat
WHERE links.link_cat = '.$category[$idx]['cat_id'].'
ORDER BY links.link_name');
// Continue if there is any links in the category
if ( is_array($links) ) {
// Run through all the links in the category
foreach ($links as $link) {
$right_tabel .= '
<tr>
<td><a href="handler.php?cmd=link&id='.$link['link_id'].'" onmouseover="setStatus(\'
http://'.$link['ref'].'\'); return true;" onmouseout="setStatus(\'\'); return true;">'.$link['name'].'</a> - ['.$link['hits'].' hits]</td>
</tr>';
}
}
else {
$right_tabel .= '
<tr>
<td>Der er ikke oprettet nogen links i denne kategori endnu</td>
</tr>';
}
$right_tabel .='
<tr>
<td><br /></td>
</tr>';
}
}// foreach ($category as $cat)
$left_tabel .= '</table></td>';
$right_tabel .= '</table></td>';
// Print tables
print($left_tabel);
print($right_tabel);
}// if ( is_array($category) )
else {
?>
<td>Der er ikke oprettet nogen kategorier endnu</td>
<?php
}
?>
</tr>
</table>
[/snip]
Du må lige skrive hvis der er noget du ikke forstår