我这是第二次发帖,我被困在这里差不多一个星期了。我有一个网站,我需要通过管理面板更改个人资料信息。现在的问题是,每当我点击编辑按钮并对配置文件进行更改,如果更改名称或电子邮件更改被接受,但当我尝试更改地址,如通过下拉列表更改国家/地区,然后我更改城市accourding到所选国家和提交那些变化我没有给我什么意思在数据库中没有做出任何改变而不是改变我在县,省列中没有得到任何东西他们变成空白没有数据我希望你得到我的观点!让我告诉你代码
edit_profileoverseasadmin.php
<script>
$(document).ready(function(){
$("form").submit(function(){
var e = document.getElementById("select");
var strUser = e.options[e.selectedIndex].text;
document.getElementById("hidden20").value = strUser;
var e1 = document.getElementById("selectcity");
var strUser1 = e1.options[e1.selectedIndex].text;
document.getElementById("hidden31").value = strUser1;
var e2 = document.getElementById("selectcontinent");
var strUser2 = e2.options[e2.selectedIndex].text;
document.getElementById("hidden32").value = strUser2;
var e3 = document.getElementById("selectprovince");
var strUser3 = e3.options[e3.selectedIndex].text;
document.getElementById("hiddenprovince").value = strUser3;
});
});
</script>
<script>
function OverseasValidation() {
$("#loaderIcon").show();
var e = document.getElementById("select");
var strUser = e.options[e.selectedIndex].text;
document.getElementById("hidden20").value = strUser;
var e1 = document.getElementById("selectcity");
var strUser1 = e1.options[e1.selectedIndex].text;
document.getElementById("hidden31").value = strUser1;
var e2 = document.getElementById("selectcontinent");
var strUser2 = e2.options[e2.selectedIndex].text;
document.getElementById("hidden32").value = strUser2;
var e3 = document.getElementById("selectprovince");
var strUser3 = e3.options[e3.selectedIndex].text;
document.getElementById("hiddenprovince").value = strUser3;
var rate_value;
if (document.getElementById('male').checked) {
rate_value = document.getElementById('male').value;
}
else{
rate_value = document.getElementById('female').value;
}
document.getElementById("hidden25").value = rate_value;
jQuery.ajax({
url: "<?php echo base_url();?>check_validation.php",
data:'hidden1='+$("#hidden1").val()+'&hidden2='+$("#hidden2").val()+'&hidden3='+$("#hidden3").val()+'&hidden4='+$("#hidden4").val()+'&hidden5='+$("#hidden5").val()+'&hidden6='+$("#hidden6").val()+'&hidden15='+$("#hidden15").val()+'&hiddencardholder='+$("#hiddencardholder").val()+'&hiddenaddress='+$("#hiddenaddress").val()+'&hiddenzip='+$("#hiddenzip").val()+'&hiddencardno='+$("#hiddencardno").val()+'&hiddencardexpiry='+$("#hiddencardexpiry").val()+'&cardcvv='+$("#cardcvv").val(),
type: "POST",
success:function(data){
if(data == "Success")
{
var x = document.createElement("INPUT");
x.setAttribute("type", "submit");
x.setAttribute("value","Register");
$("#user-availability-status10").html(x);
//document.getElementById("hidden1").value = data;
$("#loaderIcon").hide();
}
else if(data == "<span class='status-not-available'>Enter correct Card CVV format.</span>"){
$("#user-availability-status11").html(data);
$("#loaderIcon").hide();
}
else{
$("#user-availability-status11").html(data);
("#loaderIcon").hide();
}
},
error:function (){}
});
}
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>name.php",
data:'phone='+$("#phone").val(),
type: "POST",
success:function(data){
$("#countrydropdown").html(data);
$("#loaderIcon").hide();
var e1 = document.getElementById("select");
e1.options[e1.selectedIndex].text = document.getElementById("hdcountry").value;
var e2 = document.getElementById("selectcontinent");
e2.options[e2.selectedIndex].text = document.getElementById("hdcontinent").value;
},
error:function (){}
});
var city = "13";
var country = "AF";
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>editcity.php",
type: "POST",
success:function(data){
$("#citydropdown").html(data);
$("#loaderIcon").hide();
var e1 = document.getElementById("selectcity");
e1.options[e1.selectedIndex].text = document.getElementById("hdcity").value;
},
error:function (){}
});
});
</script>
<script type="text/javascript">
$(document).ready(function () {
var country_code = "AF";
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>province_state.php",
data: { country_code : country_code},
type: "POST",
success:function(data){
// alert(data);
$("#provincedropdown").html(data);
$("#loaderIcon").hide();
var e1 = document.getElementById("selectprovince");
e1.options[e1.selectedIndex].text = document.getElementById("hdprovince").value;
},
error:function (){}
});
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>district.php",
//data:'phone='+$("#phone").val(),
type: "POST",
success:function(data){
$("#districtdropdown").html(data);
$("#loaderIcon").hide();
},
error:function (){}
});
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>tehsil.php",
//data:'phone='+$("#phone").val(),
type: "POST",
success:function(data){
$("#tehsildropdown").html(data);
$("#loaderIcon").hide();
},
error:function (){}
});
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>uc.php",
//data:'phone='+$("#phone").val(),
type: "POST",
success:function(data){
$("#ucdropdown").html(data);
$("#loaderIcon").hide();
},
error:function (){}
});
});
</script>
function checkstate() {
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>check_state.php",
//data:'cnic='+$("#cnic").val(),
data:'state='+$("#state").val(),
type: "POST",
success:function(data){
$("#user-availability-status111").html(data);
document.getElementById("hiddenstate").value = data;
$("#loaderIcon").hide();
},
error:function (){}
});
}
function checkAddress() {
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>check_address.php",
//data:'cnic='+$("#cnic").val(),
data:'address='+$("#address").val(),
type: "POST",
success:function(data){
$("#address-availability").html(data);
document.getElementById("hiddenaddress").value = data;
$("#loaderIcon").hide();
},
error:function (){}
});
}
function checkCity() {
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>check_city.php",
//data:'cnic='+$("#cnic").val(),
data:'city='+$("#city").val(),
type: "POST",
success:function(data){
$("#city-availability").html(data);
document.getElementById("hiddencity").value = data;
$("#loaderIcon").hide();
},
error:function (){}
});
}
function checkCardcvv() {
var e = document.getElementById("select");
var strUser = e.options[e.selectedIndex].text;
document.getElementById("hidden20").value = strUser;
var e1 = document.getElementById("selectcity");
var strUser1 = e1.options[e1.selectedIndex].text;
document.getElementById("hidden31").value = strUser1;
var e2 = document.getElementById("selectcontinent");
var strUser2 = e2.options[e2.selectedIndex].text;
document.getElementById("hidden32").value = strUser2;
var e3 = document.getElementById("selectprovince");
var strUser3 = e3.options[e3.selectedIndex].text;
document.getElementById("hiddenprovince").value = strUser3;
var rate_value;
if (document.getElementById('male').checked) {
rate_value = document.getElementById('male').value;
}
else{
rate_value = document.getElementById('female').value;
}
document.getElementById("hidden25").value = rate_value;
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>check_cardcvv.php",
//data:'cnic='+$("#cnic").val(),
data:'cardcvv='+$("#cardcvv").val(),
type: "POST",
success:function(data){
$("#cardcvv-availability").html(data);
document.getElementById("hiddencardcvv").value = data;
$("#loaderIcon").hide();
},
error:function (){}
});
}
function checkSilsala() {
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>check_silsala.php",
//data:'cnic='+$("#cnic").val(),
data:'silsala='+$("#silsala").val(),
type: "POST",
success:function(data){
$("#user-availability-status7").html(data);
document.getElementById("hidden7").value = data;
$("#loaderIcon").hide();
},
error:function (){}
});
}
function checkBlock() {
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>check_block.php",
//data:'cnic='+$("#cnic").val(),
data:'block='+$("#block").val(),
type: "POST",
success:function(data){
$("#user-availability-status8").html(data);
document.getElementById("hidden8").value = data;
$("#loaderIcon").hide();
},
error:function (){}
});
}
function checkProvince() {
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>check_province.php",
//data:'cnic='+$("#cnic").val(),
data:'state='+$("#state").val(),
type: "POST",
success:function(data){
$("#user-availability-status9").html(data);
document.getElementById("hidden9").value = data;
$("#loaderIcon").hide();
},
error:function (){}
});
}
function checkContinent() {
$("#loaderIcon").show();
jQuery.ajax({
url: "<?php echo base_url();?>check_continent.php",
//data:'cnic='+$("#cnic").val(),
data:'continent='+$("#continent").val(),
type: "POST",
success:function(data){
$("#user-availability-status39").html(data);
document.getElementById("hidden39").value = data;
$("#loaderIcon").hide();
},
error:function (){}
});
}
</script>
<body>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah')
.attr('src', e.target.result)
.width(120)
.height(150);
};
reader.readAsDataURL(input.files[0]);
}
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$(".my-activity").click(function(event) {
var total = 120;
/*var lensector=$(this).find('input[name="check_list[]"]:checked').length;
document.getElementById("hidden29").value = lensector;
var lenoffice=$(this).find('input[name="check_list1[]"]:checked').length;
document.getElementById("hidden30").value = lenoffice;*/
var countsectors = 0;
var countoffice = 0;
var countwings = parseInt(document.getElementById("wings").value);
//alert(checkedBoxes);
$(".my-activity:checked").each(function() {
if($(this).val() == "UC Member"){
countoffice += 1;
total += 5000;
}
else if($(this).val() == "Tehsil President"){
countoffice += 1;
total += 10000;
}
else if($(this).val() == "District President"){
countoffice += 1;
total += 25000;
}
else if($(this).val() == "Commerce & Trade"){
countwings += 1;
//total += 10000;
}
/*else if($(this).val() == "Commerce"){
countwings += 1;
//total += 10000;
}*/
else if($(this).val() == "Industry"){
countwings += 1;
//total += 10000;
}
else if($(this).val() == "Lawyer"){
countwings += 1;
//total += 25000;
}
else if($(this).val() == "Doctor"){
countwings += 1;
//total += 10000;
}
else if($(this).val() == "Minorities"){
countwings += 1;
//total += 25000;
}
else if($(this).val() == "Women_Development"){
countwings += 1;
//total += 10000;
}
else if($(this).val() == "Functionary"){
countwings += 1;
//total += 25000;
}
else if($(this).val() == "Other"){
countwings += 1;
var data = '<input type="text" id="otherfield" name="otherfield">';
$("#otherfield").html(data);
//total += 25000;
}
else{
countsectors += 1;
total += 120;
}
});
if (total == 120) {
$('#amount').val('120');
} else {
$('#amount').val(total);
}
document.getElementById("hidden29").value = countsectors;
document.getElementById("hidden30").value = countoffice;
document.getElementById("wings").value = countwings;
var amount = total;
document.getElementById("payment").value = total;
});
});
</script>
<script>
window.onload=function() {
document.getElementById("countrydropdown").onchange=function() {
//var period = this.value;
var e = document.getElementById("select");
var strUser = e.options[e.selectedIndex].value;
document.getElementById("hidden20").value = strUser;
//var e = document.getElementById("select");
var ctry = e.options[e.selectedIndex].text;
document.getElementById("hiddencountry").value = ctry;
jQuery.ajax({
url: "<?php echo base_url();?>province_state.php",
data: { country_code : strUser},
type: "POST",
success:function(data){
$("#provincedropdown").html(data);
$("#loaderIcon").hide();
},
error:function (){}
});
}
document.getElementById("provincedropdown").onchange=function() {
var e = document.getElementById("selectprovince");
var strUser = e.options[e.selectedIndex].value;
document.getElementById("hidden20").value = strUser;
var ctry = e.options[e.selectedIndex].text;
document.getElementById("hiddenstate").value = ctry;
var rate_value;
if (document.getElementById('male').checked) {
rate_value = document.getElementById('male').value;
}
else{
rate_value = document.getElementById('female').value;
}
document.getElementById("hidden25").value = rate_value;
var e1 = document.getElementById("select");
var strUser1 = e1.options[e1.selectedIndex].value;
jQuery.ajax({
url: "<?php echo base_url();?>city.php",
data: { country : strUser1 , city : strUser },
type: "POST",
success:function(data){
$("#citydropdown").html(data);
//document.getElementById("hiddencity").value = strUser;
$("#loaderIcon").hide();
},
error:function (){}
});
}
}
</script>
<?php $this->load->view('header'); ?>
<!--Form Start-->
<div class="row">
<div class="col-md-offset-3 col-md-9">
<h2><legend class="alignright"><u>Edit Profile</u></legend></h2>
<div class="col-lg-5">
<h3>Membership # <strong><?php echo $membershipno;?></strong></h3>
<h4><?php echo $province; ?></h4>
</div>
<?php echo form_open_multipart("admin/editprofileoverseas/".$id);?>
<div class="col-lg-4 col-lg-offset-1">
<?php if($pic_path != './profile_pics/'):?>
<img id="blah" src="<?php echo base_url().$pic_path;?>" height="150"/>
<?php else: ?>
<img id="blah" src="https://nabobil.no/assets/default_profile_pic-05d39cb795bbb98e10c104b8f4aba70677a3f9f6c13253bf94f16181e9ee5a99.gif" height="150"/>
<?php endif; ?>
<input type='file' name="myFile" onchange="readURL(this)"; />
</div>
<br>
<br>
<span class="col-md-4 col-md-offset-4" style="color:#D91E18"> <?php echo $message;?></span>
<div class="controls col-md-5">
<label class="control-label" for="username">Full Name</label> *<br>
<!--<input type="text" id="firstname" name="firstname" placeholder="" class="input-xlarge" onBlur="checkAvailability2()">-->
<?php echo "<input name='firstname' type='text' class='form-control' id='firstname' value='$first_name' />";?><span id="user-availability-status2"></span>
</div>
<input type="hidden" id="hidden2" name="hidden2" value="">
<div class="controls col-lg-5">
<label class="control-label" for="relation">Father / Husband Name</label><br>
<?php echo "<input name='relation' type='text' class='form-control' id='relation' value='$relation' />";?>
</div>
<div class="controls col-lg-5">
<label class="control-label" for="username">Date Of Birth</label><br>
<?php echo "<input name='dob' type='text' class='form-control' id='dob' value='$birth_date' />";?><span id="user-availability-status15"></span>
</div>
<!--<div class="control col-md-5">
<label class="control-label" for="email">CNIC</label><br>
<?php echo "<input name='cnic' type='text' class='form-control' id='cnic' value='$cnic' />";?><span id="user-availability-status3"></span>
</div>
<input type="hidden" id="hidden3" name="hidden3" value="">-->
<input type="hidden" id="hidden4" name="hidden4" value="">
<input type="hidden" id="hidden15" name="hidden15" value="">
<!--<div class="controls col-md-5">
<label class="control-label" for="email">E-mail</label> *
<br>
<?php echo "<input name='email' type='text' class='form-control' id='email' value='$email' />";?><span id="user-availability-status1"></span>
</div>
<input type="hidden" id="hidden1" name="hidden1" value="">
<input type="hidden" id="hidden5" name="hidden5" value="">
<div class="control col-md-5">
<label class="control-label" for="email">Gender</label><br>
<input type="radio" name="gender" value="male" id="male" checked="true"> Male
<input type="radio" name="gender" value="female" id="female"> Female<br>
</div>
<input type="hidden" id="hidden25" name="hidden25" value="">-->
<!-- <div class="control col-md-5">
<label class="control-label" for="email">Profile Picture</label><br>
<input type='file' name="myFile" onchange="readURL(this)"; />
</div>-->
<div class="control col-md-5">
<label class="control-label" for="email">Landline Number</label><br>
<?php echo "<input name='phone' type='text' class='form-control' id='phone' value='$phone' />";?>
</div>
<div class="control col-md-5">
<label class="control-label" for="email">Mobile Number</label> *<br>
<!--<input type="tel" name="mobile" id="mobile" placeholder="03012345678" onBlur="checkMobile()">-->
<?php echo "<input name='mobile' type='text' class='form-control' id='mobile' value='$mobile' />";?><span id="user-availability-status6"></span>
</div>
<input type="hidden" id="hidden6" name="hidden6" value="">
<div class="control col-md-5">
<label class="control-label" for="email">Email Address</label> *<br>
<!--<input type="tel" name="mobile" id="mobile" placeholder="03012345678" onBlur="checkMobile()">-->
<?php echo "<input name='email' type='text' class='form-control' id='email' value='$email' />";?><span id="user-availability-status1"></span>
</div>
<div class="control col-md-5">
<label class="control-label" for="email">Mailing Address</label> *<br>
<?php echo "<textarea name='mailingaddress' rows='10' cols='160' class='form-control' id='mailingaddress'>$mailingaddress</textarea>";?>
</div>
<!--<div class="control col-md-5">
<label class="control-label" for="email"></label><br>
<span id="countrydropdown"></span>
</div>-->
<div class="row Weddings">
</div>
<!--<div class="control col-md-5">
<label class="control-label" for="username">Continent</label><br>
<input type="text" id="continent" name="continent" placeholder="" class="input-xlarge" onBlur="checkContinent()"><span id="user-availability-status39"></span>
</div>
<input type="hidden" id="hidden39" name="hidden39" value="">-->
<div class="control col-md-5">
<label class="control-label" for="email">Country</label> *<br>
<span id="countrydropdown"></span>
<?php
$selected='';
$con=mysqli_connect("localhost","","","freedomorg");
$sql=mysqli_query($con,"SELECT id,name FROM countries");
if(mysqli_num_rows($sql)){
$select= '<select name="select" id="select">';
while($rs=mysqli_fetch_array($sql))
{
if($rs['name']===$country)
{
$select.='<option selected="selected" value="'.$rs['id'].'">'.$rs['name'].'</option>';
}
else
{
$select.='<option value="'.$rs['id'].'">'.$rs['name'].'</option>';
}
}
$select.='</select>';
echo $select;
}
//P}OaK[oW@s[U
?>
</div>
<input type="hidden" id="hidden20" name="hidden20" value="">
<input type="hidden" id="hiddencountry" name="hiddencountry" value="">
<div class="control col-md-5">
<label class="control-label" for="email">Continent</label> *<br>
<select id="selectcontinent">
<option value="Asia">Asia</option>
<option value="Africa">Africa</option>
<option value="North America">North America</option>
<option value="South America">South America</option>
<option value="Antarctica">Antarctica</option>
<option value="Europe">Europe</option>
<option value="Australia">Australia</option>
</select>
</div>
<input type="hidden" id="hidden32" name="hidden32" value="">
<div class="control col-md-5">
<label class="control-label" for="username">State/Province *</label><br>
<span id="provincedropdown"></span>
<?php
// $country_code = $_POST["country_code"];
$con=mysqli_connect("localhost","","","freedomorg");
$sql1=mysqli_query($con,"SELECT code FROM countries WHERE name='$country'");
$row = mysqli_fetch_assoc($sql1);
$result=$row['code'];
$sql=mysqli_query($con,"SELECT code,name FROM regions WHERE country='$result' order by name ASC");
if(mysqli_num_rows($sql)){
$select= '<select name="select" id="selectprovince">';
while($rs=mysqli_fetch_array($sql)){
if($rs['name']===$province)
{
$select.='<option selected="selected" value="'.$rs['code'].'">'.$rs['name'].'</option>';
}
else
{
$select.='<option value="'.$rs['code'].'">'.$rs['name'].'</option>';
}
}
$select.='</select>';
echo $select;
}
?>
<!-- <input type="text" id="state" name="state" placeholder="" class="input-xlarge" onBlur="checkstate()"><span id="user-availability-status111"></span><!--onBlur="OverseasValidation()"><span id="user-availability-status11"></span>-->
</div>
<input type="hidden" id="hiddenprovince" name="hiddenprovince" value="">
<input type="hidden" id="hiddenstate" name="hiddenstate" value="">
<?php echo "<input name='hdprovince' type='hidden' id='hdprovince' value='$province' />";?>
<?php echo "<input name='hdcountry' type='hidden' id='hdcountry' value='$country' />";?>
<?php echo "<input name='hdcity' type='hidden' id='hdcity' value='$city' />";?>
<?php echo "<input name='hdcontinent' type='hidden' id='hdcontinent' value='$continent' />";?>
<input type="hidden" id="hidden21" name="hidden21" value="">
<div class="control col-md-5">
<label class="control-label" for="username">City *</label><br>
<span id="citydropdown"></span>
<?php
$con=mysqli_connect("localhost","","","freedomorg");
$sql=mysqli_query($con,"SELECT id,name FROM cities WHERE name != '' order by name ASC");
if(mysqli_num_rows($sql)){
$select= '<select name="select" id="selectcity">';
while($rs=mysqli_fetch_array($sql)){
if($rs['name']===$city)
{
$select.='<option selected="selected" value="'.$rs['id'].'">'.$rs['name'].'</option>';
}
else
{
$select.='<option value="'.$rs['id'].'">'.$rs['name'].'</option>';
}
}
$select.='</select>';
echo $select;
}
?>
<!--<input type="text" id="city" name="city" placeholder="" class="input-xlarge" onBlur="OverseasValidation()"><span id="user-availability-status11"></span>-->
</div>
<input type="hidden" id="hiddencity" name="hiddencity" value="">
<input type="hidden" id="hidden31" name="hidden31" value="">
<div class="row">
<div class="col-md-offset-3 col-md-9 col-lg-offset-4 col-lg-8">
<?php echo form_submit('submit', 'Submit');?> <?php echo form_close();?>
</div>
</div>
<br>
<br>
</div>
</div>
</div>
<!-- Tehsil Council wali bakwas-->
<br>
<br>
<!--Form End-->
<!-- Footer Start -->
<?php $this->load->view('footer'); ?>
</body>
</html>
答案 0 :(得分:1)
我无法发表评论,但可能有很多原因。
评论中的人正在讨论mysqli_connect,因为您的信息肯定是错误的。 您必须将用户和密码作为第二个和第三个参数放在mysqli_connect函数中,具体取决于您的生产服务器ID /密码。 您没有任何错误代码?
另外,毫无疑问,Code igniter有一个内置数据库..请看这里:https://www.codeigniter.com/user_guide/tutorial/news_section.html(取决于您的CI版本)
答案 1 :(得分:1)
请尝试mvc结构,我希望此代码可以帮助您正确找到您的问题
您应该将数据库详细信息添加到database.php
文件
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'root',
'database' => 'db_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
这是我的控制器文件
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('sitemodel');
}
public function index()
{
$data['countries'] = $this->sitemodel->get_country();
$this->load->view('welcome_message',$data);
}
}
然后Sitemodel.php
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Sitemodel extends CI_Model {
function __construct() {
// Call the Model constructor
parent::__construct();
}
function get_country() {
$this->db->select('id,name');
$this->db->from('countries');
$data = $this->db->get()->result();
return $data;
}
}
最后我添加了带下拉列表的视图文件
<select name="country" id="country">
<?php
foreach($countries as $country)
{
?>
<option value="<?= $country->id?>">"<?= $country->name?></option>
<?php
}
?>
</select>
我希望这会对你有所帮助