爆破数组如何使其正确?

发布于 2025-02-10 20:04:20 字数 949 浏览 1 评论 0原文

我在php中有一个表格,有一些名为技能[]的复选框,我想知道如何在此代码中以正确的方式爆炸和发布正确的方式,我已经习惯了通常的msqli或普通帖子语法,但是,现在我将乡村国家城市下拉列出来,我无法找到一种正确发布它的方法:

<?php
$skills = array('PHP', 'JavaScript', 'jQuery', 'AngularJS');
$commasaprated = implode(',' , $skills);
?>

<?php
//insert.php

if(isset($_POST['country']))
{
    include('database_connection.php');
    $query = "
    INSERT INTO country_state_city_form_data (country, state, city, skills) 
    VALUES(:country, :state, :city, :skills)
    ";
    $statement = $connect->prepare($query);
    $statement->execute(
        array(
            ':country'      =>  $_POST['country'],
            ':state'        =>  $_POST['state'],
            ':city'         =>  $_POST['hidden_city'],
            ':skills'           =>  $_POST['skills'],
        )
    );
    $result = $statement->fetchAll();

    if(isset($result))
    {
        echo 'done';
    }

}

?>

I have a form in php wich has some checkboxes named skills[], I want to know how to implode and post the correct way in this code, I was used to the usual msqli or normal post syntax, but now that I made country state city dropdown I can't figure out a way to correctly post it:

<?php
$skills = array('PHP', 'JavaScript', 'jQuery', 'AngularJS');
$commasaprated = implode(',' , $skills);
?>

<?php
//insert.php

if(isset($_POST['country']))
{
    include('database_connection.php');
    $query = "
    INSERT INTO country_state_city_form_data (country, state, city, skills) 
    VALUES(:country, :state, :city, :skills)
    ";
    $statement = $connect->prepare($query);
    $statement->execute(
        array(
            ':country'      =>  $_POST['country'],
            ':state'        =>  $_POST['state'],
            ':city'         =>  $_POST['hidden_city'],
            ':skills'           =>  $_POST['skills'],
        )
    );
    $result = $statement->fetchAll();

    if(isset($result))
    {
        echo 'done';
    }

}

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你如我软肋 2025-02-17 20:04:20

在内部您if(ISSET($ _ post ['country'])))

incode> include() do:

$checkedSkills = implode(", ", $_POST['skills']);

...

$statement->execute(
    array(
        ':country'      =>  $_POST['country'],
        ':state'        =>  $_POST['state'],
        ':city'         =>  $_POST['hidden_city'],
        ':skills'           =>  $checkedSkills,
    )
);

Inside you're if(isset($_POST['country']))

After you're include() do:

$checkedSkills = implode(", ", $_POST['skills']);

...

$statement->execute(
    array(
        ':country'      =>  $_POST['country'],
        ':state'        =>  $_POST['state'],
        ':city'         =>  $_POST['hidden_city'],
        ':skills'           =>  $checkedSkills,
    )
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文