Jump to content

need help displaying record count


d3vilr3d

Recommended Posts

Hi all,

 

I'm pretty new to PHP and is trying to edit an existing listing script.  What I am trying to do is to show a number of listing per sub categories on the page.  But I am having a hard time pulling out the data and display the count.  Heres the code I have so far.  Please help me.

 

thanks so much in advance.

 

<?PHP

if (!defined("MC_KEY")) die("Security Error.");

 

include_once('includes/database.php');

require_once('config.php');

 

if ($_REQUEST[action]=="showreg" || !isset($_REQUEST[action])) {

        $categories = $info->getCategories();

// INCLUDE REGIONID IN URL, IF NECESSARY

if (isset($_REQUEST[regionid])) $region_req = "&regionid=".$_REQUEST[regionid];

        for ($i = 0; $i < sizeof($categories); $i++){

$url = "?action=showads$region_req&categoryid=".$categories[$i][id];

echo "<TABLE class='list_categories'>";

echo "<TR valign='top'>";

echo "<TD>";

echo "<div class='main_category_name'>".$categories[$i][name]."</div>\n";

echo "</TD>";

echo "<TD>";

$sub_categories = $info->getSubCategories($categories[$i][id]);

$res = sprintf("SELECT * FROM `ad` WHERE `sub_category_id` = .$sub_categories");

$result = array($res);

$count = count($result);

echo "<TABLE class='category_table_$site_default_lang'>\n";

echo "<TR>\n";

for ($j = 0; $j < sizeof($sub_categories); $j++) {

$url = "?action=showads$region_req&categoryid=".$categories[$i][id]."&subcategoryid=".$sub_categories[$j][id];

if ($j%5 == 0) echo "<TD class='category_column'>";

echo "<A href='$url'>".$sub_categories[$j][name]." ".$count."</A><BR/>\n";

}

echo "</TR>\n";

echo "</TABLE>";

echo "</TD>";

echo "</TR>";

echo "<TR><TD> </TD><TD><hr style='height:1px; color: #ccc;width:420px;'/></TD></TR>";

echo "</TABLE>";

        }

}

?>

Link to comment
Share on other sites

Guest
This topic is now 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.