How to pass the val value obtained by the select statement in php to the SQL statement

Source: Internet
Author: User
In php, how does the select command obtain the val value and transmit it to the SQL statement? click the data on the right on the left.
The code is as follows:
Script

Document. getElementById ("sel"). value = "3 ";
Document. getElementById ("sel"). fireEvent ("onchange ");
Function demo ()
{
Var d = document. getElementById ("sel"). value;
Document. getElementById ("tex"). value = d;
Alert (d );

}
Script

Select Foreach (range ('A', 'z') as $ val ){Echo"";Echo $ val;Echo"";}?>

Require_once 'admin/config. php ';
If ($ conn ){
$ Stmt = odbc_exec ($ conn, "select distinct [category] FROM [Website product View] WHERE [category] like 'a % '");
If ($ stmt ){
$ Arr = array ();
While ($ row = odbc_fetch_array ($ stmt )){
$ Arr [] = $ row;
}
For ($ I = 0; $ I {
If ($ I % 4 = 0 ){
Echo"";
}
?>



}
}
}
?>


Reply to discussion (solution)

What is the data received by php?
Print_r ($ _ GET );
Print_r ($ _ POST );

Print_r ($ _ POST );

Execute the command on the original page to pass the alert (d) value to the SQL statement.

If there is no need to change, ajax will be used. the select box value will be passed to php, and php will return json data to js to complete page ING.

Is there an instance!

Receiving data is A-Z


Html implementation:
1 3

PHP:
$ Sel = $ _ POST ['sel '];

In this case, the submit button is still required. It means you can click on the right side of the page.

In this case, the submit button is still required. It means you can click on the right side of the page.
After the form is submitted, the select value can be passed to the server.

Sorry for your question...

In this case, the submit button is still required. It means you can click on the right side of the page.

Ajax. when you click it on the left, the js function is triggered. use ajax to upload the selected value to the server to obtain the corresponding data and put it back to the right.

Override the onchange event processing function. send an ajax request in the function to send the sel value to the server. The result is displayed to the right.
There are many examples of ajax on the Internet.

How does the onchange event send an ajax request in the function to send the sel value to the server. I still don't know about ajax

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.