Jump to content

PHP code help


dannybrazil

Recommended Posts

Hello

in my site (http://www.classifieds-4free.net/portuguese/por-post-categories.php?city=Toronto)

i have all the categories as a link (as you can see)

but only in the next page after you hit a category you can see all the posts.

 

i wanted to know if its possible to get the number of posts of each category in this page ?

(e.g Books (12) , and so on...)

 

i know i suppose to connect to the database and do the regular count of rows , in my next pageit looks like that :

$data = mysql_query("SELECT  * FROM _Form_Nr_4 WHERE category='$category' AND city='$city' ORDER BY post_time DESC") or die

 

as you can see all the posts r in one database and for each city and category(link farwarded) there is another quering.

 

well i hope you understand what im asking

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/100820-php-code-help/
Share on other sites

$data = mysql_query("SELECT  * FROM _Form_Nr_4 WHERE category='$category' AND city='$city' ORDER BY post_time DESC") or die
$number=mysql_num_rows($data);

 

That will get you the number of records retrieved for a particular category

 

Then all you have to do is

 

print "$number";

 

Next to the category list

Link to comment
https://forums.phpfreaks.com/topic/100820-php-code-help/#findComment-515684
Share on other sites

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.