Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我已经在上面解释过了 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="style_Php_Mysql_Codeigniter - Fatal编程技术网

Php 我已经在上面解释过了 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="style

Php 我已经在上面解释过了 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="style,php,mysql,codeigniter,Php,Mysql,Codeigniter,我已经在上面解释过了 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css" /> </head> <body> <div class="containe

我已经在上面解释过了
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">

    <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css" />
    </head>
    <body>  
    <div class="container-fluid">
        <div class="row main-content">          
            <div class="col-xs-12 col-sm-10 col-md-10 col-lg-10 col-sm-offset-2 col-md-offset-2 col-lg-offset-2">

                <form id='students' method='post' name='students' action='index.php'>
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <tr>
                                <th><input class='check_all' type='checkbox' onClick="select_all()"/></th>
                                <th>S. No</th>
                                <th>Country Name</th>
                                <th>Country Number</th>
                                <th>Country Phone code</th>
                                <th>Country code</th>
                            </tr>
                            <tr>
                                <td><input type='checkbox' class='case'/></td>
                                <td><span id='snum'>1.</span></td>
                                <td><input class="form-control" type='text' id='countryname_1' name='countryname[]'/></td>
                                <td><input class="form-control" type='text' id='country_no_1' name='country_no[]'/></td>
                                <td><input class="form-control" type='text' id='phone_code_1' name='phone_code[]'/></td>
                                <td><input class="form-control" type='text' id='country_code_1' name='country_code[]'/> </td>
                            </tr>
                        </table>
                        <button type="button" class='btn btn-danger delete'>- Delete</button>
                        <button type="button" class='btn btn-success addmore'>+ Add More</button>
                    </div>
                </form>
            </div>  

        </div>  
    </div><!-- /container -->

    <div class="clearfix"></div>
    <script src="js/auto.js"></script>
  </body>
</html>
$(".delete").on('click', function() {
    $('.case:checkbox:checked').parents("tr").remove();
    $('.check_all').prop("checked", false); 
    check();
});
var i=$('table tr').length;

$(".addmore").on('click',function(){
    count=$('table tr').length;

    var data="<tr><td><input type='checkbox' class='case'/></td><td><span id='snum"+i+"'>"+count+".</span></td>";
    data +="<td><input class='form-control' type='text' id='countryname_"+i+"' name='countryname[]'/></td> <td><input class='form-control' type='text' id='country_no_"+i+"' name='country_no[]'/></td><td><input class='form-control' type='text' id='phone_code_"+i+"' name='phone_code[]'/></td><td><input class='form-control' type='text' id='country_code_"+i+"' name='country_code[]'/></td></tr>";
    $('table').append(data);
    row = i ;
    $('#countryname_'+i).autocomplete({
    source: function( request, response ) {
        $.ajax({
            url : 'ajax.php',
            dataType: "json",
            method: 'post',
            data: {
               name_startsWith: request.term,
               type: 'country_table',
               row_num : row
            },
             success: function( data ) {
                 response( $.map( data, function( item ) {
                    var code = item.split("|");
                    return {
                        label: code[0],
                        value: code[0],
                        data : item
                    }
                }));
            }
        });
    },
    autoFocus: true,            
    minLength: 0,
    select: function( event, ui ) {
        var names = ui.item.data.split("|");
        id_arr = $(this).attr('id');
        id = id_arr.split("_");                 
        $('#country_no_'+id[1]).val(names[1]);
        $('#phone_code_'+id[1]).val(names[2]);
        $('#country_code_'+id[1]).val(names[3]);
    }               
  });

  $('#country_code_'+i).autocomplete({
    source: function( request, response ) {
        $.ajax({
            url : 'ajax.php',
            dataType: "json",
            method: 'post',
            data: {
               name_startsWith: request.term,
               type: 'country_table',
               row_num : row
            },
             success: function( data ) {
                 response( $.map( data, function( item ) {
                    var code = item.split("|");
                    return {
                        label: code[3],
                        value: code[3],
                        data : item
                    }
                }));
            }
        });
    },
    autoFocus: true,            
    minLength: 0,
    select: function( event, ui ) {
        var names = ui.item.data.split("|");
        id_arr = $(this).attr('id');
        id = id_arr.split("_");         
        $('#country_no_'+id[1]).val(names[1]);
        $('#phone_code_'+id[1]).val(names[2]);
        $('#countryname_'+id[1]).val(names[0]);
    }               
  });
  $('#phone_code_'+i).autocomplete({
    source: function( request, response ) {
        $.ajax({
            url : 'ajax.php',
            dataType: "json",
            method: 'post',
            data: {
               name_startsWith: request.term,
               type: 'country_table',
               row_num : row
            },
             success: function( data ) {
                 response( $.map( data, function( item ) {
                    var code = item.split("|");
                    return {
                        label: code[2],
                        value: code[2],
                        data : item
                    }
                }));
            }
        });
    },
    autoFocus: true,            
    minLength: 0,
    select: function( event, ui ) {
        var names = ui.item.data.split("|");
        id_arr = $(this).attr('id');
        id = id_arr.split("_");                     
        $('#country_no_'+id[1]).val(names[1]);
        $('#country_code_'+id[1]).val(names[3]);
        $('#countryname_'+id[1]).val(names[0]);
    }               
  });
  $('#country_no_'+i).autocomplete({
    source: function( request, response ) {
        $.ajax({
            url : 'ajax.php',
            dataType: "json",
            method: 'post',
            data: {
               name_startsWith: request.term,
               type: 'country_table',
               row_num : row
            },
             success: function( data ) {
                 response( $.map( data, function( item ) {
                    var code = item.split("|");
                    return {
                        label: code[1],
                        value: code[1],
                        data : item
                    }
                }));
            }
        });
    },
    autoFocus: true,            
    minLength: 0,
    select: function( event, ui ) {
        var names = ui.item.data.split("|");
        id_arr = $(this).attr('id');
        id = id_arr.split("_");                     
        $('#country_code_'+id[1]).val(names[3]);
        $('#phone_code_'+id[1]).val(names[2]);
        $('#countryname_'+id[1]).val(names[0]);
    }               
  });

    i++;
});

function select_all() {
    $('input[class=case]:checkbox').each(function(){ 
        if($('input[class=check_all]:checkbox:checked').length == 0){ 
            $(this).prop("checked", false); 
        } else {
            $(this).prop("checked", true); 
        } 
    });
}

function check(){
    obj=$('table tr').find('span');
    $.each( obj, function( key, value ) {
        id=value.id;
        $('#'+id).html(key+1);
    });
}

$('#countryname_1').autocomplete({
    source: function( request, response ) {
        $.ajax({
            url : 'ajax.php',
            dataType: "json",
            method: 'post',
            data: {
               name_startsWith: request.term,
               type: 'country_table',
               row_num : 1
            },
             success: function( data ) {
                 response( $.map( data, function( item ) {
                    var code = item.split("|");
                    return {
                        label: code[0],
                        value: code[0],
                        data : item
                    }
                }));
            }
        });
    },
    autoFocus: true,            
    minLength: 0,
    select: function( event, ui ) {
        var names = ui.item.data.split("|");                        
        $('#country_no_1').val(names[1]);
        $('#phone_code_1').val(names[2]);
        $('#country_code_1').val(names[3]);
    }               
});

$('#country_code_1').autocomplete({
    source: function( request, response ) {
        $.ajax({
            url : 'ajax.php',
            dataType: "json",
            method: 'post',
            data: {
               name_startsWith: request.term,
               type: 'country_code',
               row_num : 1
            },
             success: function( data ) {
                 response( $.map( data, function( item ) {
                    var code = item.split("|");
                    return {
                        label: code[3],
                        value: code[3],
                        data : item
                    }
                }));
            }
        });
    },
    autoFocus: true,            
    minLength: 0,
    select: function( event, ui ) {
        var names = ui.item.data.split("|");                    
        $('#country_no_1').val(names[1]);
        $('#phone_code_1').val(names[2]);
        $('#countryname_1').val(names[0]);
    },
    open: function() {
        $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
    },
    close: function() {
        $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
    }               
 });

 $('#country_no_1').autocomplete({
    source: function( request, response ) {
        $.ajax({
            url : 'ajax.php',
            dataType: "json",
            method: 'post',
            data: {
               name_startsWith: request.term,
               type: 'country_no',
               row_num : 1
            },
             success: function( data ) {
                 response( $.map( data, function( item ) {
                    var code = item.split("|");
                    return {
                        label: code[1],
                        value: code[1],
                        data : item
                    }
                }));
            }
        });
    },
    autoFocus: true,            
    minLength: 0,
    select: function( event, ui ) {
        var names = ui.item.data.split("|");                    
        $('#country_code_1 ').val(names[3]);
        $('#phone_code_1').val(names[2]);
        $('#countryname_1').val(names[0]);
    },
    open: function() {
        $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
    },
    close: function() {
        $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
    }               
});

$('#phone_code_1').autocomplete({
    source: function( request, response ) {
        $.ajax({
            url : 'ajax.php',
            dataType: "json",
            method: 'post',
            data: {
               name_startsWith: request.term,
               type: 'phone_code',
               row_num : 1
            },
             success: function( data ) {
                 response( $.map( data, function( item ) {
                    var code = item.split("|");
                    return {
                        label: code[2],
                        value: code[2],
                        data : item
                    }
                }));
            }
        });
    },
    autoFocus: true,            
    minLength: 0,
    select: function( event, ui ) {
        var names = ui.item.data.split("|");                    
        $('#country_code_1 ').val(names[3]);
        $('#country_no_1 ').val(names[1]);
        $('#countryname_1').val(names[0]);
    },
    open: function() {
        $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
    },
    close: function() {
        $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
    }               
});
if($_POST['type'] == 'country_table'){
    $row_num = $_POST['row_num'];
    $name = $_POST['name_startsWith'];
    $query = "SELECT name, numcode, phonecode, iso3 FROM country where UPPER(name) LIKE '".strtoupper($name)."%'";
    $result = mysqli_query($con, $query);
    $data = array();
    while ($row = mysqli_fetch_assoc($result)) {
        $name = $row['name'].'|'.$row['numcode'].'|'.$row['phonecode'].'|'.$row['iso3'].'|'.$row_num;
        array_push($data, $name);   
    }   
    echo json_encode($data);
}
echo json_encode($data);
<html>

                    <div class="ui-widget">
                        <label for="name">Name:</label> <input id="name">
                    </div>

<script>
        $.ajax({
            type: 'POST',
            url: '<?php echo base_url();?>' + 'filter/data',
            dataType: "json",
            success: function (data) {
                var mydata = data; // Replace ... with your JavaScript Object
                var output = "";
                var email = [];
                for (var key in mydata) {
                    if (mydata.hasOwnProperty(key)) {
                        name.push(mydata[key]["name"]);
                        output += "<tr><td>" + mydata[key]["name"] + "</td>";

                    }
                }
                var nameTags = name;  // Array passing into autocomplete
                var name_change=$("#name").autocomplete({                     
                    source: nameTags,
                    select:function(event,ui){
                        $("#name").val(ui.item.value);
                        var name_val=$(this).val();
                    }
                });
}
});
</script>
</html>
class Home extends CI_Controller {
    function __construct(){
        parent::__construct();
        $this->load->helper('url');
    }
    function index(){
        $data['title']='View_Country';
        $this->load->view('view_home',$data);
    }
}
var controller = 'country';
    var base_url = '<?php echo site_url();?>';
    url= base_url + controller + '/get_country
class Home extends CI_Controller {
        function __construct(){
            parent::__construct();
            $this->load->helper('url');
        }

        function index(){
            $data['title']='View_Country';
            $this->load->view('view_home',$data);
        }

        function get_country(){
            $this->load->model('get_country');
            $data = array();
            $data['list'] = $this->get_country->get_country_detail();
            $this->load->view('view_country', $data);

        }
    }
class get_country extends CI_Model {
            function __construct(){
              parent::__construct();
            }
            public function get_country_detail(){  
                $search = $this->input->get('term');
                if($search == ''){
                    return array();
                }
                $query=$this->db->query("SELECT name, numcode, phonecode, iso3 FROM country where UPPER(name) LIKE '".strtoupper($name)."%'");
                if($query->num_rows() > 0)
                    return $query->result();  
                else return NULL;                     
            }
        }
<?php if(isset($list) && count($list)) : 
           foreach($list as $row) : 
                 $name = $row['name'].'|'.$row['numcode'].'|'.$row['phonecode'].'|'.$row['iso3'].'|'.$row_num;
                 array_push($data, $name);   
           endforeach; 
           echo json_encode($data); 
endif; ?>