1

I have the following:

$allform = $_POST['allform'];
        parse_str($allform, $output);

        $allquery="SELECT * FROM wp_users";
        $names = array();   
        $allresult=mysql_query($allquery) or die(mysql_error()); ?>

        <?php while($rows=mysql_fetch_array($allresult)){  

            $names[] = $rows['user_email']; 

        }

The allform variable is a jQuery serialize string:

  var allform = $('form#all').serialize();

Basically, I want to put the values from the form in the front end into a mysql select query in the back end.

The form is a bunch of checkboxes so the idea is that the SELECT something will have different number of values depending on what the user checks. Im not even sure if the serialize function is worth it here, but I cant think of any thing. Any ideas?

Thanks

1 Answer 1

2

the serialize function only makes sense if you use ajax. example:

$.post("test.php", $("form#all").serialize());

test.php would be the url to you php script.
on the PHP side you will be able to handle it the same way as any other form submission, e.g. every form field will be it's own index in the post array

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

2 Comments

Yeah I am using the jQuery.ajax, not .post. I just dont know how to get the values in the SELECT query on the server-side..
as you're posting a form to the server, post would make more sense in your case. then simply print_r the $_POST variable on the server side and you should see all the form fields listed in the array

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.