
-----------------------------------
Amailer
Fri Dec 19, 2003 1:40 am

Listing help
-----------------------------------
http://gfx-pro.ath.cx/?module=Downloads

see that?

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?


$dlcat_name = $download_cat[$i]['dlcat_name'];


is where i get the names. (from mysql)


   $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++)
   {
....


-----------------------------------
PaddyLong
Fri Dec 19, 2003 10:35 am


-----------------------------------
this should do it I think....


print ("\n");
    for($i = 0; $i < $total_dlcats-1; $i += 2) 
   { 
       print("\t\n\t\t".$download_cat[$i]['dlcat_name']."\n\t\t".$download_cat[$i+1]['dlcat_name']."\n\t\n");
   }
print("");


-----------------------------------
Amailer
Fri Dec 26, 2003 4:09 pm


-----------------------------------
dammit!
problem..is there is an odd number of categories, the last category won't display...help

-----------------------------------
PaddyLong
Fri Dec 26, 2003 4:44 pm


-----------------------------------
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.


print ("\n");
$column = 1;
foreach ($download_cat as $curr_cat)
{
	if ($column == 1)
	{
		print ("\t\n\t\t".$curr_cat['dlcat_name']."\n");
		$column = 2;
	}
	elseif ($column == 2)
	{
		print ("\t\t".$curr_cat['dlcat_name']."\n\t\n");
		$column = 1;
	}
}
if ($column == 2)
{
	print ("\t\t\n\t\n");
}
print ("");


-----------------------------------
Amailer
Fri Dec 26, 2003 5:19 pm


-----------------------------------
pff, saved. Thanks.

-----------------------------------
Amailer
Fri Dec 26, 2003 5:58 pm


-----------------------------------
Hey, i got subcategories, and i want to list them below the category name
ie.

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

-----------------------------------
PaddyLong
Fri Dec 26, 2003 11:01 pm


-----------------------------------
that should be no biggy...

just throw in a br and a for loop in the cells
..something along the lines of


print ("\n"); 
$column = 1; 
foreach ($download_cat as $curr_cat) 
{ 
   if ($column == 1) 
   { 
      print ("\t\n\t\t".$curr_cat['dlcat_name']."");
      foreach ($curr_cat['subcats'] as $curr_subcat)
      {
		print($curr_subcat);
      }
      print("\n"); 
      $column = 2; 
   } 
   elseif ($column == 2) 
   { 
      print ("\t\t".$curr_cat['dlcat_name']."");
      foreach ($curr_cat['subcats'] as $curr_subcat)
      {
		print($curr_subcat);
      }
      print ("\n\t\n"); 
      $column = 1; 
   } 
} 
if ($column == 2) 
{ 
   print ("\t\t\n\t\n"); 
} 
print (""); 


-----------------------------------
Amailer
Sat Dec 27, 2003 5:44 pm


-----------------------------------
ble that way did not work well, but i figured it out using almost the same thign :D

Thanks..I FINISHED IT!

-----------------------------------
PaddyLong
Sat Dec 27, 2003 11:41 pm


-----------------------------------
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

-----------------------------------
Amailer
Sun Jan 11, 2004 2:01 am


-----------------------------------

//
// THIS IS WHERE WE LIST THE CATEGORIES IN TABLES
//

$dlcat_di = "\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\n\t\t" . $curr_cat['catsub_name'] . " (" . $total_dl1 . ")\n";
      $column = 2;
   }
   elseif ($column == 2)
   {
	  $total_dl1 = total_dl($curr_cat['catsub_id'], DLS_TABLE, dl_category);

      $dlcat_di .= "\t\t" . $curr_cat['catsub_name'] . " (" . $total_dl1 . ")\n\t\n";
      $column = 1;
   }
}
if ($column == 2)
{
   $dlcat_di .= "\t\t\n\t\n";
}
      
 $dlcat_di .= "";


-----------------------------------
PaddyLong
Sun Jan 11, 2004 1:07 pm


-----------------------------------
which lists...
http://jor.termix-zero.d2g.com/?module=downloads 
?
nice  :)

-----------------------------------
Amailer
Wed Mar 03, 2004 11:04 pm


-----------------------------------
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 ]
