选择下拉列表更改时重新显示php mysql表

时间:2022-10-21 23:50:29

Hey, so i have a table on my page as a result of this code:

嘿,所以我在这个代码的结果是在我的页面上有一个表:

$result = mysql_query("Select * from porders, porders_detail, parts where porders.order_no = porders_detail.order_no and porders_detail.om_part_no = parts.om_part_no") or die(mysql_error());

This query gets fired off at the start. But i want to display a dropdown and using jQuery have an "On change" include the value of the dropdown into the mysql query above and re-display the results in the table that i talked about at the start?

此查询在开始时被触发。但我想显示一个下拉列表并使用jQuery有一个“On change”包含上面的mysql查询下拉列表的值,并重新显示我在开始时谈到的表中的结果?

Any ideas?

有任何想法吗?

Just to clarify i can do the whole jquery bit, its just advice on what php to put so it does display the table at the start but i also have the option to re-send the query with included dropdown value.

只是为了澄清我可以做整个jquery位,它只是建议什么PHP的建议,所以它确实在开始时显示表,但我也可以选择重新发送包含下拉值的查询。

2 个解决方案

#1


1  

I would try using the jquery ajax functions and load a php file that connects to the mysql database and brings back information based on the string entered in the textbox and have an onclick event on the list items that triggers the start of the script.

我会尝试使用jquery ajax函数并加载一个连接到mysql数据库的php文件,并根据在文本框中输入的字符串返回信息,并在列表项上触发脚本启动的onclick事件。

#2


0  

Maybe you're looking for json_encode or something like this?

也许你正在寻找json_encode或类似的东西?

http://www.php.net/manual/en/function.json-encode.php

http://www.php.net/manual/en/function.json-encode.php

You can transform the resultset of your query into JSON, then write it to the PHP output, and with jQuery fill the dropdown values.

您可以将查询的结果集转换为JSON,然后将其写入PHP输出,并使用jQuery填充下拉值。

In the dropdown's OnChange event, you should re-call the PHP with $.get() or something.

在下拉列表的OnChange事件中,您应该使用$ .get()或其他东西重新调用PHP。

#1


1  

I would try using the jquery ajax functions and load a php file that connects to the mysql database and brings back information based on the string entered in the textbox and have an onclick event on the list items that triggers the start of the script.

我会尝试使用jquery ajax函数并加载一个连接到mysql数据库的php文件,并根据在文本框中输入的字符串返回信息,并在列表项上触发脚本启动的onclick事件。

#2


0  

Maybe you're looking for json_encode or something like this?

也许你正在寻找json_encode或类似的东西?

http://www.php.net/manual/en/function.json-encode.php

http://www.php.net/manual/en/function.json-encode.php

You can transform the resultset of your query into JSON, then write it to the PHP output, and with jQuery fill the dropdown values.

您可以将查询的结果集转换为JSON,然后将其写入PHP输出,并使用jQuery填充下拉值。

In the dropdown's OnChange event, you should re-call the PHP with $.get() or something.

在下拉列表的OnChange事件中,您应该使用$ .get()或其他东西重新调用PHP。