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"); ?>
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

Thank you for the help so far. I will try to implement the example you have given me. If not that works with my "special" - php script  ;D i will try the "third party script" section. ;)

Thanks again.

Great site by the way!

Best regards
Link to comment
Share on other sites

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.