Have an account? Sign in
Login  Register  Facebook
how to take a result of 2 queries together?
Hello,
I have two tables tblproduct and tblaccessory . my DBMS is mysql. i created a search engine. now i want to take results from both tables and display it together. i used union function. but,
i code something like this;
if($recs['accessory_id']=null)
//display something

but an error generates "undefined variable $recs['accessory_id']"
what can i do for this.. this is mostly like mysql problem, but i thought to have a try on this forum, maybe there is a php solution...
thank you...
Started: September 19, 2011 Latest Activity: September 19, 2011 php mysql union queries error
2 Answers
First thing you need to do is change the '=' in your if statement to a '=='.

Second, $recs has not been assigned to anything. You need to give $recs a value before you can use it in the if statement. In your case, assigning it the value of the result set from your DB query.

Posted: Go
In: September 19, 2011

Oh! im sorry... I actually did code it that way.. I just shorten the code here, and i did use '=='
September 19, 2011

fist of all
$recs[\'accessory_id\']=null
is not mean $recs[\'accessory_id\'] is null or equal null no, its mean set $recs[\'accessory_id\'] null [make it nulled] you can use instead of this
if(is_null($recs[\'accessory_id\']))
or use isset()
resources

Posted: MacOS
In: September 19, 2011

thank you.......
September 19, 2011

Hey, thanx guys... I found a way to do it... A mysql way... using UNION properly ;) But, thanx a lot!!!
September 19, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer