获取Foreach数据

时间:2014-07-05 11:04:20

标签: php jquery arrays mysqli foreach

我正在尝试获取foreach数据我正在使用jquery提交页面而不需要刷新因为某些原因jQuery没有检索foreach数据,它需要遍历每个管理输入字段以分别查看每个数据。 / p>

如果不可能,我不会使用JQuery,但我想问

PHP:

if(isset($_POST['admin_add']) AND is_array($_POST['admin_add'])) {
    foreach($_POST['admin_add'] as $admin_add) {
        if(strlen($admin_add) > 0) {
            // $sql=mysql_query("insert into hobbies(hobby)values('$hobby')");
        }
    }
}

die('<h3>'.$admin_add.'<h3/>');

jQuery的:

$(document).ready(function () {

    var clan_url_string = window.location.search.substring(1);
    // Make a function that returns the data, then call it whenever you
    // need the current values
    function getData() {
        return {
            clan_title_edit: $('#clan_title_edit').val(),
            clan_des: $('#clan_des').val(),
            admin_add: $('#admin_add').val(),
            //remember_me: ($('#remember_me').is(':checked')) ? 1 : 0
        }
    }

    $(window).load(function(){
        $('#background_cycler').fadeIn(1500);//fade the background back in once all the images are loaded
        setInterval('cycleImages()', 4000); // run every 4s
    });


    function loading(e) {
        $('#loading_status').show();
    }

    function hide_loading(e) {
        $('#loading_status').hide();
    }

    function success_message(e) {
        $('#success_login').html("We're Just Signing You In");
    }

    function clearfields() {
        $('#login-username').val('');  //Clear the user login id field
        $('#login_password').val('');  //Clear the user login password field        
    }

    function check(e) {
        e.preventDefault();
        $.ajax({
            url: 'ajax/save_settings.php?'+clan_url_string,
            type: 'post',
            error: function () {
                //If your response from the server is a statuscode error. do this!!!'

                hide_loading(e);
                $('#status_message').html('<b>Something Has Gone Wrong</b><br> Please Try Again Later');
            },

            beforeSend: function () {
                loading(e);
            },

            data: {
                clan_title_edit: $('#clan_title_edit').val(), 
                clan_des: $('#clan_des').val(),
                admin_add: $('#admin_add').val(),
                remember_me: ($('#remember_me').is(':checked')) 
            }, // get current values

            success: function (data) {
                //if your response is a plain text. (e.g incorrect username or password)
                hide_loading(e);
                $('#status_message').hide();
                $('#status_message').fadeIn(1000).html(data);
            }
        });
    }

    // Don't repeat so much; use the same function for both handlers
    $('#login_content').keyup(function (e) {
        if (e.keyCode == 13) {
            var username = $('#login-username').val();
            check(e);
        }
    });

    $('#submit_clan_settings').click(function (e) {
        if (e.keyCode != 13) {
            check(e);
        }
    });

有php和jquery

由于

  

是的,它易于注入SQL,还没有解决这个问题,我应该使用mysqli$db->);

0 个答案:

没有答案