d3vilr3d Posted October 1, 2007 Share Posted October 1, 2007 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 = "®ionid=".$_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 More sharing options...
Barand Posted October 1, 2007 Share Posted October 1, 2007 You've had an answer to this in PHP Help forum. Don't waste our time by expecting an answer in this forum too. Read the forum guidelines DON'T double post again. Link to comment Share on other sites More sharing options...
Recommended Posts