Jump to content

[SOLVED] Total In Joomla Component


hellouthere

Recommended Posts

I have this code...

 


<div id="con_types1">
	<div id="heading_Types">Categories</div>
	<div id="con_types2">
		<div class="con_types3">
			<?php
				$query = "SELECT *
						  FROM #__hp_cats
						  WHERE parent = 0";
				$database->setQuery( $query );
				$crows = $database->loadObjectList( );

				foreach( $crows as $crow ){
					$query = "SELECT COUNT(*)
							  FROM #__hp_properties
							  WHERE cat = ".$crow->id;
					$database->setQuery( $query );
					$cnt = $database->loadResult();

					?>
						<a href="index.php?option=com_hotproperty&task=viewcats&id=<?=$crow->id?>&Itemid=<?=$Itemid?>"><?=$crow->name?></a> (<?=$cnt?>)
					<?php
					$query = "SELECT *
							  FROM #__hp_cats
							  WHERE parent = ".$crow->id;
					$database->setQuery( $query );
					$scrows = $database->loadObjectList( );
					if( count( $scrows ) ){
						echo '<ul>';
						foreach( $scrows as $scrow ){
							$query = "SELECT COUNT(*)
  										  FROM #__hp_properties
									  WHERE cat = ".$scrow->id;
							$database->setQuery( $query );
							$cnt = $database->loadResult();
							?>
							<li><a href="index.php?option=com_hotproperty&task=viewcats&id=<?=$scrow->id?>&sub=1&Itemid=<?=$Itemid?>"><?=$scrow->name?></a> (<?=$cnt?>)</li>
							<?php
						}
						echo '</ul>';							
					}
					echo '<br />';
				}
			?>

		</div>
	</div>
</div>

 

At the moment it takes the total of each subcategory and display it next to the linked subcategory...

 

I would also like the total of all the subcategories displayed next to the category...

 

i.e.

 


San Antonio (6)
     North (2)
     East (1)
     South (0)
     West (3)


 

Any ideas or completed code would be much appreciated...

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/62079-solved-total-in-joomla-component/
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.