gpt4 book ai didi

php - JQWidgets 组合框键入的值未回显或提交到数据库

转载 作者:行者123 更新时间:2023-11-29 20:47:51 24 4
gpt4 key购买 nike

下面是我正在使用的代码,当我从数据库中选择值时,它们会被提交到数据库,但是如果我输入数据库中没有的内容并且我希望将其提交,则 PHP 不会提交或回显它。请帮帮我。

谢谢。

 <?php
//Jason File
#Include the connect.php file
include('db_connect2.php');
//get county of selected district
$query = "SELECT * FROM primary_schools ";

$result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$customers[] = array(
'Emis_No' => $row['Emis_No'],
'District' => $row['District'],
'County' => $row['County'],
'Subcounty' => $row['Subcounty'],
'Parish' => $row['Parish'],
'School' => $row['School']
);
}

echo json_encode($customers);
?>

//Script
<script type=”text/javascript”>
$(document).ready(function () {
//start EMIS code
var customersSourcel =
{
datatype: "json",
datafields: [
{ name: 'Emis_No'},
{ name: 'District'},
{ name: 'County'},
{ name: 'Subcounty'},
{ name: 'Parish'},
{ name: 'School'}
],
url: 'includes/emis.php',
cache: false,
async: false
};

var customersAdapterl = new $.jqx.dataAdapter(customersSourcel);

$("#emis_no").jqxComboBox(
{
source: customersAdapterl,

width: 200,
height: 25,
promptText: "emis",
displayMember: 'Emis_No',
valueMember: 'Emis_No'
});

$("#emis_no").bind('select', function(event)
{
if (event.args)
{
var index = $("#emis_no").jqxComboBox('selectedIndex');
if (index != -1)
{
var record = customersAdapterl.records[index];
document.form1.district.value = record.District;
$("#county").jqxComboBox({ disabled: false});
document.form1.county.value = record.County;
$("#sub_county").jqxComboBox({ disabled: false});
document.form1.sub_county.value = record.Subcounty;
$("#parish").jqxComboBox({ disabled: false});
document.form1.parish.value = record.Parish;
$("#school").jqxComboBox({ disabled: false});
document.form1.school.value = record.School;
}
}
});

最佳答案

在 PHP 文件开头使用 $customers = array(); 初始化 $customers 数组,然后开始使用 $customers[ 将值插入其中] = ...

关于php - JQWidgets 组合框键入的值未回显或提交到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38307199/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com