如何在php中显示数据库中的多个复选框值

时间:2018-10-03 18:14:49

标签: php mysql


Please see database's image also 我想显示数据库中的复选框值。

Example : my value is 25,26.
So, How can i display it one by one ?
such as,
-- 1st value is : 25.
--2nd Value is : 26.

我的代码:

    $db = new mysqli("localhost","paroshic_paroshic","kxmcwQzLTrTR","paroshic_matri2018jl");
    $sql = "select * from tbldatingusermaster order by userid desc";
    $result = $db->query($sql);

    while($data = $result->fetch_object()){
    echo $data->education; //My value is 25,26

}

谢谢。

2 个答案:

答案 0 :(得分:0)

您可以将HTML标记写到带有回显的页面上,您知道的。所以基本上就是这样:

while($data = $result->fetch_object()){
    echo '<input type="checkbox" name="check" value="'.$data->educationid.'">'.$data->educationid.'<br>';
}

答案 1 :(得分:0)

我认为您正在寻找的难题之一可能是apply()从给定的字符串explode(即25,26)创建一个整数数组

$data->educationid