Jump to content

newbie on php, needs help with the "get"- function


xprez

Recommended Posts

Hi all.

I have done some php scripting, but now i`m stuck! (newbie)

I want this ad-script to show the amount of ads in each category on the front page, in "()" behind the category name, and that  part is working fine, but how do i get the scipt to get the amount of ads in the subcategories? Someone please help.

Belowe is the code of the "index.php" page. The red txt is the part that`s working fine about getting the amount of ads in the main categories, but what about it do i have to change the include the amount of ads in subcategories?

<?php include ("session.php");
$nav_section = "search";
include ("header.php");
[color=red]get_categories($_GET['cat_id']);

get_ads_in_cat($_GET['cat_id'], "full", "");[/color]

include ("footer.php"); ?>
yeah, i'm not sure what that is. But, if you want to get a count then you'd have to do a query of some sort that tells you how many results there are. Like this:

[code]<?php
$sql = "SELECT * FROM categories";
$results = mysql_query($sql);
$num_rows = mysql_num_rows($results);
echo "There are $num_rows ads in this category.";
?>[/code]

That will return the number of results.

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.