javascript和php选择,javascript – 动态选择选项php和mysql

我知道这个问题已被多次询问,但我已经尝试了几个小时但没有任何效果,我是一个用PHP和ajax的菜鸟,所以,我可能会错过一个我不知道的小事,我是什么的试图在这里实现的是,我希望用户选择一个食物组,并根据该组成一系列成分.

我单独测试了我的process.php文件,它运行良好,我还测试了脚本会发生什么,当我将它注释掉并键入alert(parent)时,从$.ajax开始的行不起作用我实际上得到了选择的选项的价值,所以我在这里做错了什么?或者我错过了一个导入?

P.S我正在使用bootstrap 3.0进行设计

这是我的HTML代码

Food Group *

// retreiving the recipe groups

$RecipeGroup = new FoodGroup();

$data = $RecipeGroup->findAll();

foreach ($data->results() as $recipegroup) {

// displaying the options

echo ''.$recipegroup->food_group_name.'';

}

?>

Ingredients *

// retreiving the recipe groups

$ingredients = new Ingrident();

if(Input::exists()){

$data = $ingredients->findByGroup(Input::get('food-group'));

}else

$data = $ingredients->findByGroup(1);

foreach ($data->results() as $ingredient) {

// displaying the options

echo ''.$ingredient->ingrident_name.'';

}

?>

Ingredient not listed ?

Add New Ingredient

这是我的剧本

function ajaxfunction(parent)

{

$.ajax({

url: 'process.php?food-group=' + parent;

success: function(data) {

$("#ingredients").html(data);

}

});

}

这是我的process.php文件

mysql_connect('localhost', 'root','');

mysql_select_db("online_recipes");

$result = mysql_query("SELECT * FROM `ingrident` WHERE `food_group_id_fk` = " . mysql_real_escape_string($_GET['food-group']));

while(($data = mysql_fetch_array($result)) !== false)

echo '', $data['ingrident_name'],'';

我的进口清单

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值