[英]combining php ajax jquery for drop downs populated by sql
I am trying to get three different bits of php to work in order and work in a way that is easy for the user. 我正在尝试使php的三个不同部分按顺序工作,并且以对用户来说容易的方式工作。 This is the some of the code I have already that gets data from a database.
这是我已经从数据库获取数据的一些代码。 I have a similar statement to this in a drop down that I need to populate using the answer from this first bit of code when it changes I also need to take the answers of both of these and put them into another sql statement that will display a set of results.
我在下拉列表中有一个与此类似的语句,当它更改时,我需要使用第一部分代码中的答案进行填充,我还需要同时获取这两个答案,并将它们放入另一个显示以下内容的sql语句中结果集。 I know I need to use something like jquery or ajax but I am unsure of how to use it in WordPress to get the desired effect.
我知道我需要使用诸如jquery或ajax之类的东西,但是我不确定如何在WordPress中使用它来获得理想的效果。
<select name="raceTrack2" onchange="">
<?php
$postids = $wpdb->get_col("SELECT trackName FROM " . $trackTableName . ";");
foreach ($postids as $value)
{
echo '<option>' . $value . '</option>' ;
}
?>
</select>
Any help would be appreciated 任何帮助,将不胜感激
There are several ways to skin this cat. 有几种方法可以给这只猫蒙皮。 Since you mentioned jQuery/Ajax I will guide you through the high level steps using those technologies:
自从您提到jQuery / Ajax以来,我将指导您使用这些技术完成高级步骤:
At a high level, this should do it. 在较高级别,这应该做到。 As I said, there are many ways to skin this cat.
正如我说的,有很多方法可以给这只猫蒙皮。 This is probably the simplest way to go and does not require a post-back/round-trip to your server.
这可能是最简单的方法,不需要回退/往返服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.