1

I am working on a HTML email, I need to attach forms, but attach forms that have a value less then or equal to 37 (<= 37)

I think I sorta figured out my problem that I am having with this piece of code :

           if ($this->input->post('form') <= 37) {
              ...........................................
            }

What I think this is searching for is if the array form[] actually has 37 keys in it not the if the value is less then or equal to 37.

What I want is to see if the array form has values less then if it does attach those forms, then the next thing I want to check is if the array form has a value >= 38 then attach the next set of forms.

This is what I have tried :

            if ($this->input->post('form') <= 37) {
                // Attach all the forms with a value of less then or equal to 37
            }
            if ($this->input->post('form') >= 38) {
               //Attach all the forms with a value of greater then or equal to 38
            }

Is this possible?

Edit 1

Just to clear up my question the problem I was/am having is that I want to check if the values in my form[] array are less then or equal to 37, if they are attach all forms with ID less then or to 37. If they are not then attach all the forms with ID greater then or equal to 38. Hopefully this clears up the question.

Edit 2

Thanks to the help of okok with his tip on how to get the value quite simple, I just wasn't even thinking of doing anything like that. Good job okok

here is the snippet of code that does the emailing if any one is interested!

6
  • What does the post() method do? Commented Apr 13, 2013 at 13:33
  • In Codeigniter the $this->input->post(''); is exactly the same as $_POST['']; in plain old Php Commented Apr 13, 2013 at 13:35
  • Fair enough. Makes me wonder why people use it though. I mean, isn't the point of frameworks to make things easier to type? Commented Apr 13, 2013 at 14:42
  • Its used to be automatically run through the XSS Filter I think, like for instance doing this : $this->input->post('form', TRUE) will enable xss clean for that specific post variable if you don't have the global xss clean filter on all the time. Commented Apr 13, 2013 at 14:51
  • 1
    Ah, okay. That makes sense now :) Commented Apr 13, 2013 at 16:13

1 Answer 1

1

your question is bit unclear, anyway, to check values > < or = do this

    if(is_array($this->input->post('form')) && count($this->input->post('form')) > 0){
       foreach($this->input->post('form') as $value){
        if($value > 37){
        //do somenthing
        }
         if($value <= 38){
        //do somenthing
        }

         //etc ..
        }
    }

to check how many keys the array has do this:

if(count($this->input->post('form')) > 37){

}
if(count($this->input->post('form')) <= 38){

}
Sign up to request clarification or add additional context in comments.

7 Comments

@Kolink i added both solutions , since here he ask for counting keys What I think this is searching for is if the array form[] actually has 37 keys in it not the if the value is less then or equal to 37.
I updated my original post. I am currently working your solution okok
I'm still working on this btw. Still having problems, but you set me on the right track.
All is good now! Thanks for this super easy fix, I didn't even think of doing a foreach on that... I'm silly. Also updated my original post!
@RixhersAjazi glad to being helpfull so :D , have nice time and happy coding!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.