使用Ajax更新数据库 [英] Updation in database using Ajax
问题描述
我有2个表银行主数据和分行详细信息,银行代码作为一个共同的领域。
i设计了一个表格,我根据特定的银行代码使用ajax过滤分支,我很好,直到这.....现在我希望这些记录的字段应该在一个单独的字段中,以便我可以更改我的数据itselfe和使用ajax可以更新onblur事件数据库......如何这样做吗?
这是我的代码,用于显示有类似bank_code的banches的信息
[PHP] elseif($ name ==" select_bank_code")
{
$ sql =" SELECT * FROM bankbranches WHERE bank_code =''"。$ q。"''" ;;
$ result = mysql_query($ sql);
echo"< table width =''100%''>" ;;
$ i = 0;
while($ row = mysql_fetch_array($ result))
{
$ bcode = $ row [''bank_code''];
$ brcode = $ row [''branch_code' '];
$ badd = $ row [''branch_address''];
$ pin = $ row [''branch_address''];
$ bc =" bank_code";
echo"< input name =''branch_code [$ i]''type =''hidden''value =' '$ row [branch_code]''/>" ;;
echo"< tr>< td>银行代码< / td>< td>< input type =' 'text''name =''bcode [$ i]''value =''"。$ bcode。"''onblur =''modufy_rec(''"。$ bcode。"'',''' "。$ brcode。"'',此.value,''bank_code'');''>< / td>" ;;
echo"< tr>< ; td>分行代码< / td>< td>< input type =''text''name =''brcode [$ i]''value =''"。$ brcode。"''onblur =''modufy_rec(''"。$ bcode。"'',''"。$ brcode。"'',此.value,''branch_code'');''>< / td> ;" ;;
echo"< tr>< td>分支地址< / td>< td>< input type =''text''name =''baddress [$ i]''value =''"。$ badd。"''onblur ='' modufy_rec(''"。$ bcode。"'',''"。$ brcode。"'',此.value,''branch_address'');''>< / td>" ;
echo"< tr>< td> Pincode< / td>< td>< input type =''text''name =''pincode [$ i]' 'value =''"。$ pin。"''onblur =''modufy_rec(''"。$ bcode。"'',''"。$ brcode。"'',此.value ,''pincode'');''>< / td>" ;;
$ i + 1;
}
echo"< / table>" ;;
} [/ PHP]
使用此我正在显示值,但onblur不工作,这个功能需要生成查询的必要字段,这是最终调用PHP的javascript函数
i have 2 tables bank master and branch details having bankcode as a common feild .
i have designed a form in which i am filtering branches according to a particular bank code using ajax , i an fine till this ..... now i want that fields of these records should come in a separate field so that i can change my data there itselfe and using ajax can update database on onblur event ...... how to do this ?
this is my code for displaying information about banches having similar bank_code
[PHP]elseif($name == "select_bank_code")
{
$sql="SELECT * FROM bankbranches WHERE bank_code = ''".$q."''";
$result = mysql_query($sql);
echo "<table width=''100%''>";
$i=0;
while($row = mysql_fetch_array($result))
{
$bcode = $row[''bank_code''] ;
$brcode = $row[''branch_code''] ;
$badd = $row[''branch_address''] ;
$pin = $row[''branch_address''] ;
$bc = "bank_code";
echo "<input name=''branch_code[$i]'' type=''hidden'' value=''$row[branch_code]''/>";
echo "<tr><td>Bank Code </td><td><input type=''text'' name=''bcode[$i]'' value=''".$bcode."'' onblur=''modufy_rec(''".$bcode."'',''".$brcode."'',this .value,''bank_code'');''></td>";
echo "<tr><td>Branch Code </td><td><input type=''text'' name=''brcode[$i]'' value=''".$brcode."'' onblur=''modufy_rec(''".$bcode."'',''".$brcode."'',this .value,''branch_code'');''></td>";
echo "<tr><td>Branch address </td><td><input type=''text'' name=''baddress[$i]'' value=''".$badd."'' onblur=''modufy_rec(''".$bcode."'',''".$brcode."'',this .value,''branch_address'');''></td>";
echo "<tr><td>Pincode </td><td><input type=''text'' name=''pincode[$i]'' value=''".$pin."'' onblur=''modufy_rec(''".$bcode."'',''".$brcode."'',this .value,''pincode'');''></td>";
$i+1;
}
echo "</table>";
}[/PHP]
Using this i am getting values displayed but onblur is not working , this fuction takes necessary fields for generating query and this is javascript function which calls PHP ultimatly
推荐答案
name ==&quo t; select_bank_code")
{
name == "select_bank_code")
{
sql =" SELECT * FROM bankbranches WHERE bank_code =''"。
sql="SELECT * FROM bankbranches WHERE bank_code = ''".
q。"''" ;;
q."''";
这篇关于使用Ajax更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!