我想将驻留在模块中的 ajax 表单的结果输出到当前显示的文章中。下面是我想要完成的截图。我想通过ajax通过模块(在sidebarA中)的表单输入来修改文章中的mysql查询。
以下是通过 jumi 从模块中截断的一些格式代码:
<form action="http://fsdsonline.com/menumanager/index.php/menustab/all-meals/77-component-menus/124-alcohol-n" method="post">
<option value="AND plate = '1'">Plate FSDS only</option>
<option value="AND plate = '1'">Prep FSDS only</option>
<option value="">Plate and Prep FSDS</option>
</select><br /><select style="font-size: 12px;" name="menu">
<option value="">All Meals</option>
<input style="font-size: 12px;" onclick="location=document.menuselector.menu.options[document.menuselector.menu.selectedIndex].value;" type="button" value="Show" /></form>
<div class="success" style="display: none;">View your menu</div>
这是通过 jumi 文章中的 php 代码。
mysql_connect($hostname,$username, $password) OR DIE ('Unable to
connect to database! Please try again later.');
mysql_select_db($dbname);
$plateprep = $_POST['plateprep'];
$meal = $_POST['meal'];
$pub = $_POST['pub'];
$avocado = $_POST['avocado'];
$alcohol = $_POST['alcohol'];
$result = mysql_query("SELECT catnum, ctgry, Shrt_Desc, `desc`, ROUND(`Energ_Kcal`*`yield`*`qty` ) AS `cal` FROM allinnot a
LEFT JOIN allinfsds b
ON a.`NDB_No2` = b.id1
LEFT JOIN fdcat h ON b.product_type = h.unik
LEFT JOIN allinnot2 g ON a.`NDB_No2` = g.NDB_No
LEFT JOIN allincomp j ON a.`NDB_No2` = j.fsds_num
WHERE `own_id` = $user->id $plateprep $pub $meal $avocado $alcohol
ORDER BY `catnum`, `order`");
$cat = null;
$first = true;
while ($row = mysql_fetch_array($result)) {
if ($row['catnum'] != $cat) {
if (!$first) {
echo '</table>'; // close the table if we're NOT the first row being output.
}
$first = false; // no longer the first table, so disable this check.
echo '<p style="line-height: 12pt; font-size: 12pt;"><strong>' . $row['ctgry'] . '</strong></p>';
echo '<table>'; // start new table
$cat = $row['catnum'];
}
echo "<tr><td>" . $row['Shrt_Desc'] . "</td><td> " . $row['desc'] . " " . $row['cal'] . " cal</td></tr>";
}
?>
</table>
</body>
</html>
我认为我已经正确编码了查询,并且表单看起来不错,但是如何通过 ajax 连接两者?谢谢!!