![]() |
Query Help
Ok, I am not completely literate when it comes to PHP but...
What I am trying to do is modify a free link system. I have everything working but am trying to add a couple of queries to pull some more info; mainly right now the total number of links per category. First there is a link table and a category table and I am guessing that I need to work something out together. Both tables have a cat ID in them and I need to get them working together to pull the results but don't know how. If I do this, I get the total number of categories: PHP Code:
If I do this I can get the total number of links: PHP Code:
Now I need to take each of the cateogry ID's and run a query on the link table to count the total links per cat but I can't see to get it together. Any ideas or help would be greatly appreciated! Thanks for helping the PHP illiterate, Scott Z. |
<font size="1">Just to let you know, its not a good idea to use a WHERE clause when using COUNT(col)</font>
Why dont you add a catagoryid column in the links table and then grab the info from that? I say that because you have 2 columns of the same name (id) and I don't think they'll work together |
Hi assassingod,
There is a catid column in the links table but how would I go about getting the total number of links for each ID that is stored? Thanks, Scott Z. Scott Z. |
I got it to work using something like:
PHP Code:
|
Try this:
PHP Code:
|
Alrighty, got that one working. Now I was wondering if you could help me with another. :)
The table has cat_id and timestamp in it. I want to pull the row with the most recent timestamp for each cat_id. Any ideas? :) Thanks, Scott Z. |
Never mind, I actually figured this one out on my own. PHP/MYSQL, it's so fun! :)
Thanks again for all your help, Scott Z. |
Quote:
|
Quote:
|
All times are GMT. The time now is 03:37 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|