Correction php query

Hello;

I have a query as bellow:

		 $query_suggested_artandculturecat_article = "select tbarticles.title,tbarticles.deletitem,tbarticles.articleid,tbcategories.parentid,tbcategories.catid,tbarticlecategories.catname,tbphotos.photofilename,tbarticlecategories.catid
	 
from  tbarticles 
INNER JOIN tbphotos on tbphotos.articleid = tbarticles.articleid 
INNER JOIN tbarticlecategories on tbarticlecategories.articleid =  tbarticles.articleid
INNER JOIN tbcategories ON tbcategories.catid = tbarticlecategories.catid 


where tbarticles.deletitem='1'  AND tbcategories.catid ='$urlcomecatid'
ORDER BY  RAND()
LIMIT 9

Open in new window


and i want correct as :
if($urlcomecatid=166 OR 62)
 $urlcomecatid=175;

Open in new window

please let me know how can correct the query?

Thanks
MOSTAGHASSIAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Add these instructions before the query.  As other values need to be changed, just follow a similar pattern.
if($urlcomecatid == 166) $urlcomecatid=175;
if($urlcomecatid ==  62) $urlcomecatid=175;

Open in new window

0
MOSTAGHASSIAuthor Commented:
But i did it before and have problem,because after this query i have another query and with  these 'if condition' the  $urlcomecatid remain 175 while i want that only in this query(that i posted its codes) it be  175 for those conditions.
0
Ray PaseurCommented:
Then you would need to assign a different variable for use in this query.  Maybe something like this:
// SET A DEFAULT VALUE FOR THE VARIABLE
$thing = $urlcomecatid;

// CHANGE THE VARIABLE IF NEEDED
if($urlcomecatid == 166) $thing=175;
if($urlcomecatid ==  62) $thing=175;

// USE THE VARIABLE IN THE QUERY STRING
$query_suggested_artandculturecat_article =
"SELECT tbarticles.title,tbarticles.deletitem,tbarticles.articleid,tbcategories.parentid,tbcategories.catid,tbarticlecategories.catname,tbphotos.photofilename,tbarticlecategories.catid
FROM  tbarticles 
INNER JOIN tbphotos on tbphotos.articleid = tbarticles.articleid 
INNER JOIN tbarticlecategories on tbarticlecategories.articleid =  tbarticles.articleid
INNER JOIN tbcategories ON tbcategories.catid = tbarticlecategories.catid 
WHERE tbarticles.deletitem='1'  AND tbcategories.catid ='$thing'
ORDER BY  RAND()
LIMIT 9 /* etc, etc

Open in new window

If you're new to PHP and want some good learning resources, this article can help you find them (and more importantly, help you avoid the many obsolete and terrible old PHP examples that litter the internet!)
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MOSTAGHASSIAuthor Commented:
Thanks,sometimes there are simple solution that we don't think.
0
Ray PaseurCommented:
Thanks for the points, and thanks for using E-E! ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.