Author |
Message |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Fri Dec 19, 2003 1:40 am Post subject: Listing help |
|
|
http://gfx-pro.ath.cx/?module=Downloads
see that?
[ if you don't i attached an image ]
I don't want it to be listed like that, insted i want it to be like this:
( BTW its listen like that because i added a <BR> at the end of the script hm ya, other wise its like like; category 1 category 2 category 3 and etc)
code: |
CATEGORY 1 CATEGORY 2
CATEGORY 3 CATEGORY 4
CATEGORY 5 CATEGORY 6
|
In tables would be nice.
can you tell me how to do that?
code: |
$dlcat_name = $download_cat[$i]['dlcat_name'];
|
is where i get the names. (from mysql)
code: |
$download_cat = array();
$result = mysql_query("SELECT * FROM " . DLCAT_TABLE);
while ($row = mysql_fetch_array($result)) {
$download_cat[] = $row;
}
if ( !($total_dlcats = count($download_cat)) )
{
error_message(ERROR, 'NO DOWNLOAD CATEGORIES FOUND');
}
for($i = 0; $i < $total_dlcats; $i++)
{
....
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
PaddyLong
|
Posted: Fri Dec 19, 2003 10:35 am Post subject: (No subject) |
|
|
this should do it I think....
code: |
print ("<table>\n");
for($i = 0; $i < $total_dlcats-1; $i += 2)
{
print("\t<tr>\n\t\t<td>".$download_cat[$i]['dlcat_name']."</td>\n\t\t<td>".$download_cat[$i+1]['dlcat_name']."</td>\n\t</tr>\n");
}
print("</table>");
|
|
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Fri Dec 26, 2003 4:09 pm Post subject: (No subject) |
|
|
dammit!
problem..is there is an odd number of categories, the last category won't display...help |
|
|
|
|
![](images/spacer.gif) |
PaddyLong
|
Posted: Fri Dec 26, 2003 4:44 pm Post subject: (No subject) |
|
|
sorry for delayed response (I'm up in Iqaluit and haven't had the chance to get onto compsci for a while)... but I think this one should do it. you should also be able to alter this one to allow more columns quite easily.
code: |
print ("<table>\n");
$column = 1;
foreach ($download_cat as $curr_cat)
{
if ($column == 1)
{
print ("\t<tr>\n\t\t<td>".$curr_cat['dlcat_name']."</td>\n");
$column = 2;
}
elseif ($column == 2)
{
print ("\t\t<td>".$curr_cat['dlcat_name']."</td>\n\t</tr>\n");
$column = 1;
}
}
if ($column == 2)
{
print ("\t\t<td></td>\n\t</tr>\n");
}
print ("</table>");
|
|
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Fri Dec 26, 2003 5:19 pm Post subject: (No subject) |
|
|
pff, saved. Thanks. |
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Fri Dec 26, 2003 5:58 pm Post subject: (No subject) |
|
|
Hey, i got subcategories, and i want to list them below the category name
ie.
code: |
CATEGORY 1 CATEGORY 2
sub cat 1, subcat 2, subcat 3 sub cat 1, subcat 2, subcat 3
CATEGORY 3 CATEGORY 4
sub cat 1, subcat 2, subcat 3 sub cat 1, subcat 2, subcat 3
CATEGORY 5 CATEGORY 6
sub cat 1, subcat 2, subcat 3 sub cat 1, subcat 2, subcat 3
|
Hmm. this is anoying lol |
|
|
|
|
![](images/spacer.gif) |
PaddyLong
|
Posted: Fri Dec 26, 2003 11:01 pm Post subject: (No subject) |
|
|
that should be no biggy...
just throw in a br and a for loop in the cells
..something along the lines of
code: |
print ("<table>\n");
$column = 1;
foreach ($download_cat as $curr_cat)
{
if ($column == 1)
{
print ("\t<tr>\n\t\t<td>".$curr_cat['dlcat_name']."<br>");
foreach ($curr_cat['subcats'] as $curr_subcat)
{
print($curr_subcat);
}
print("</td>\n");
$column = 2;
}
elseif ($column == 2)
{
print ("\t\t<td>".$curr_cat['dlcat_name']."<br>");
foreach ($curr_cat['subcats'] as $curr_subcat)
{
print($curr_subcat);
}
print ("</td>\n\t</tr>\n");
$column = 1;
}
}
if ($column == 2)
{
print ("\t\t<td></td>\n\t</tr>\n");
}
print ("</table>");
|
|
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Sat Dec 27, 2003 5:44 pm Post subject: (No subject) |
|
|
ble that way did not work well, but i figured it out using almost the same thign
Thanks..I FINISHED IT! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
PaddyLong
|
Posted: Sat Dec 27, 2003 11:41 pm Post subject: (No subject) |
|
|
yeah.. I wrote it blindly because I didn't have apache and all that good stuff on the computer I was on... also you would have had to modify it slightly any way, because I had no idea how you had your sub categories stored |
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Sun Jan 11, 2004 2:01 am Post subject: (No subject) |
|
|
code: |
//
// THIS IS WHERE WE LIST THE CATEGORIES IN TABLES
//
$dlcat_di = "<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#444444' width='95%'>\n";
$column = 1;
foreach ($subcat as $curr_cat)
{
$catsub_catid = $curr_cat['dlcat_id'];
if ($column == 1)
{
$total_dl1 = total_dl($curr_cat['catsub_id'], DLS_TABLE, dl_category);
$dlcat_di .= "\t<tr>\n\t\t<td><font face='Verdana' size='2' color='#666666'><a href='?module=" . $HTTP_GET_VARS['module'] . "&download_2=2or3&dlcat_id=" . $curr_cat['catsub_id'] . "&cat_name=" . $curr_cat['catsub_name'] . "&cat_name2=" . $HTTP_GET_VARS['cat_name'] . "&catsub_id=" . $HTTP_GET_VARS['catsub_id'] ."' style='text-decoration: none'>" . $curr_cat['catsub_name'] . "</a> (" . $total_dl1 . ")</font><br><br></td>\n";
$column = 2;
}
elseif ($column == 2)
{
$total_dl1 = total_dl($curr_cat['catsub_id'], DLS_TABLE, dl_category);
$dlcat_di .= "\t\t<td><font face='Verdana' size='2' color='#666666'><a href='?module=" . $HTTP_GET_VARS['module'] . "&download_2=2or3&dlcat_id=" . $curr_cat['catsub_id'] . "&cat_name=" . $curr_cat['catsub_name'] . "&cat_name2=" . $HTTP_GET_VARS['cat_name'] . "&catsub_id=" . $HTTP_GET_VARS['catsub_id'] ."' style='text-decoration: none'>" . $curr_cat['catsub_name'] . "</a> (" . $total_dl1 . ")</font><br><br></td>\n\t</tr>\n";
$column = 1;
}
}
if ($column == 2)
{
$dlcat_di .= "\t\t<td></td>\n\t</tr>\n";
}
$dlcat_di .= "</table>";
|
|
|
|
|
|
![](images/spacer.gif) |
PaddyLong
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Wed Mar 03, 2004 11:04 pm Post subject: (No subject) |
|
|
Note: url changed http://gfx-pro.ath.cx/?module=Downloads
[for those who wan't to just see how it turned out if you need to know what htis does :S] |
|
|
|
|
![](images/spacer.gif) |
|