get_cat_id and compare to cat_id in sql table
-
Hello,
I’m not as skilled with PHP and MySQL as some of you in this forum. So I would really appreciate if somebody can help me with the following.Using PHP, what is the best way of getting the cat_id for each post, then comparing it to a value in a MySQL table. And if both values are equal then get the content of that value in that table and echo it on my page.
Here is an example of what i mean:
I have 3 categories
1. Cars (cat_id is 10)
2. Bikes (cat_id is 11)
3. Planes (cat_id is 12)I have created a new table and named it “info” which contains the following:
id — cat_id — text
1 — 10 — some text for every post in the cars category
2 — 11 — some text for every post in the bikes category
3 — 12 — some text for every post in the planes categoryNow lets say I have published a post in the “Cars” category (which is cat_id 10)
Within the WP loop i want to get the cat_id for the post and compare it to the cat_id in the “info” table, then echo the appropriate text for each category/cat_id.Thank you in advance.
Artin H.
- The topic ‘get_cat_id and compare to cat_id in sql table’ is closed to new replies.