Welcome Guest, Not a member yet? Register   Sign In
Help with a database insert
#11

[eluser]Miguel Diaz[/eluser]
Great now is storing the information there is only one more problem it is sending 0 instead of the value Sad
#12

[eluser]adityamenon[/eluser]
Both values are being stored as zeroes?
#13

[eluser]Miguel Diaz[/eluser]
Yes I have the seven values insert in the database but all with zero
#14

[eluser]adityamenon[/eluser]
What happens when you echo out $this->input->post('telefonia');?

We are probably annoying everybody, this kind of thing should be done on IRC Big Grin
#15

[eluser]Miguel Diaz[/eluser]
jejej that is true Smile

I tried this to check

Code:
$categorias = array(
                    $this->input->post('telefonia'),
                    $this->input->post('computo'),
                    $this->input->post('fotografia'),
                    $this->input->post('electronica'),
                    $this->input->post('instrumentos_musicales'),
                    $this->input->post('entretenimiento'),
                    $this->input->post('reparacion'),
                    );
        
        
        foreach ($categorias as $value):
        $data = array(
               'localID' => $this->input->post('localID'),
               'categoriaID' => $value //you were doing this step twice
            );

        $this->db->insert('categoriasLocatarios', $data);
        endforeach;
        
        echo $this->input->post('telefonia');
and it is sending me a white page with nothing but i check the url and it have the values on it

http://localhost:8888/clientes_corporati...&localID=1
#16

[eluser]adityamenon[/eluser]
Why does the URL have any values? That is GET method... then your code should be $this->input->get('telefonia'); everywhere.
#17

[eluser]Miguel Diaz[/eluser]
That was totally right you make me see my stupidity I erase the method in my form when I was checking what was happening. now works great Smile

One more question I am passing the input hidden to my form with ajax in this case when the people click in the category an input hidden is added to the view through ajax I did this because I do have a lot more subcategories and subsubcategories. imagine this was just for the categories and I only have 7 categories but in one subcategory I do have 180subcategories that are related to the first category.

But I would like to have a way that if the input is not in the form do not send nothing Smile

What you think is that possible.

Thanks for all your help it is really great to find people like you
#18

[eluser]adityamenon[/eluser]
Whenever a new hidden input class is generated, make sure you add a class to it.

Before the form data is submitted, count the number of elements with that class name. If the number is 0, then the user did not select any categories. Return false in javascript to the click of the form submit button and display an alert asking them to select atleast one field.

I don't have the time to write the JS code right now... but it's very easy to do with jQuery.




Theme © iAndrew 2016 - Forum software by © MyBB