Jump to content
php.lv forumi
Sign in to follow this  
KalashaLv

posts and topics count

Recommended Posts

You. Es dumjš pašlaik esmu un netieku galā ar postu un topiku skaita izvadi.

$q = mysqli_query($conn, "SELECT COUNT(p.topic_id) AS post_count FROM posts p, topics t WHERE p.topic_id = t.id AND p.topic_id = c.id");

viņš izvada 0

un ja šādi - $q = mysqli_query($conn, "SELECT COUNT(p.topic_id) AS post_count FROM posts p, topics t WHERE p.topic_id = t.id");
viņš izvada 3 (jo datubāzē ir 1 topiks un 2 posti ar id "23")

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×