Web Analytics Made Easy -
StatCounter What is wrong with this function? - CodingForum

Announcement

Collapse
No announcement yet.

What is wrong with this function?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is wrong with this function?

    Code:
    $body.='<option value="'.$rootcat->id.'"'.$_POST['filter']==$rootcat->id?'selected':''.'>'.$rootcat->title.'</option>';
    Anyone? I can't see what it wrong!?!?!

  • #2
    PHP Code:
    $selected = ($_POST['filter']==$rootcat->id) ? 'selected' '';
    $body.='<option value="'.$rootcat->id.'" '.$selected.'>'.$rootcat->title.'</option>'
    I don't think you can have a ternary operator directly in your variable like that. You would have to do something like the above.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment


    • #3
      Thanks Worked like a charm..

      Next item of business, making more filter options

      How do I tell it to query the db when filer other than 0/empty?
      Code:
      if($_POST['filter']=='' || $_POST['filter']==0)
      I want the if statement to do it's thing when there IS a value in $POST filter
      And if 0/empty

      Code:
      if($_POST['filter']=='TRUE' || $_POST['filter']==<0) {
      // pull db WHERE id = filter value
      }
      else if($_POST['filter2']=='TRUE' || $_POST['filter2']==<0) {
      // pull db WHERE id = filter2 value
      }
      
      else {
      // do default pull from db
      }
      And so on.. How to do it how to do it

      Thanks!

      Comment


      • #4
        Use isset($_POST['filter']).

        Are you sure you want it to be less than 0?
        ||||If you are getting paid to do a job, don't ask for help on it!||||

        Comment


        • #5
          I have no idea

          I want to have different db queries from what value each of the filter drop-downs have.

          ex:

          Username - Category - status
          uname1 cat1 active
          uname2 cat2 active
          uname3 cat3 inactive


          TABLE-LIST of items.


          When selecting uname3 in username drop-down, I want the list to only display items from uname3.

          I have been using only one filter to select category, and that is working fine.

          like this:

          while (post filter = 0)
          pull default

          else

          Pull WHERE cid= catid from filter selection.

          table-display code.


          -Tom--

          Comment

          Working...
          X