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
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.