Jump to content


Photo

Need help


  • Please log in to reply
2 replies to this topic

#1 Angela

Angela
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 07 May 2006 - 04:18 PM

Here is piece of code:
!empty($purpose) ? $mpurpose=" AND purposes = '".$purpose."'" : $mpurpose = "";
!empty($marstat) ? $mmarstat=" AND marstat = '".$marstat."'" : $mmarstat = "";

It gives search results from 2 selectboxes "purpose" and "marstat". How to change first line - that when only "purpose" is selected to see in search results for both values: "purpose" +(or) "marstat"?

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 07 May 2006 - 11:00 PM

I don't think your syntax is correct here, well, I have never seen ternary expressions written like that before...
$mpurpose = (!empty($purpose)) ? " AND purposes = '".$purpose."'" : "";


#3 Angela

Angela
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 08 May 2006 - 04:38 PM

[!--quoteo(post=372142:date=May 7 2006, 06:00 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 7 2006, 06:00 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I don't think your syntax is correct here, well, I have never seen ternary expressions written like that before...
$mpurpose = (!empty($purpose)) ? " AND purposes = '".$purpose."'" : "";
[/quote]
Yes, it is correct it works, but i need help of person with knowledge of such things.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users