数据无法进入数据库(php,sql)

时间:2016-01-19 02:31:19

标签: php html sql

是的,我有一个代码,我尝试将其输入数据库

/*example data
  $areaSes = Area 1
  $row['area'] = Area 2;
*/

$area = $areaSes . ',' . $row['area'] ;
echo 'output :' . $area; 

//output
//output : Area 1 , Area 2

然后,在数据库中,只输入值1,但值2不输入 为什么会这样?

//完整代码

$plugins1 = '';
if(!empty($_POST['checkboxvar'])) {
    foreach($_POST['checkboxvar'] as $plugins) {


        $plugins;

        $sql="SELECT * FROM reportevidence where id='$plugins'";
        $result_set=mysql_query($sql);

        while($row=mysql_fetch_array($result_set))
        {
            //$area = $areaSes . ',' . $row['area'] ;

            $area = "".$areaSes.",".$row['area']."";


        }

        echo "output:".$area."";  // output: Area 1, Area 2

        $queryPass = mysql_query("update reportevidence set usedByArea='$area' where id = '$plugins' ",$conn);


        //$plugins1 .= $plugins.":";
}}

数据库 image of my db

我想要它 1区,2区

2 个答案:

答案 0 :(得分:0)

如果你在一行中循环,你是否试图连接字符串?

$area .= $areaSes . ',' . $row['area'] ;
echo 'output :' . $area; 

答案 1 :(得分:-1)

试试这个。

$area = "".$areaSes.",".$row['area']."";
echo "output:".$area."";