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...
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 1 of 1 people found this answer helpful. Did you? Yes No Oh! im sorry... I actually did code it that way.. I just shorten the code here, and i did use '=='
fist of all
$recs[\'accessory_id\']=nullis 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 2 of 2 people found this answer helpful. Did you? Yes No thank you....... Hey, thanx guys... I found a way to do it... A mysql way... using UNION properly ;) But, thanx a lot!!! |
© Advanced Web Core. All rights reserved