MySql查询中的变量插入

时间:2016-12-20 04:50:56

标签: php mysql mysqli

我从mysql表中获取一些行并在获取它之后将其插入到具有类似类型表的另一个数据库中。我想在行的一个字段中进行少量更改,并希望在其中插入固定值而不是我先获取的值。

我目前的查询如下

while ($row = mysqli_fetch_array($questions))
$cat=1;
{
    // escape your strings
    foreach($row as $key => $val)
    {
        $row[$key] = mysqli_real_escape_string($mobcon, $row[$key]);
    }
    mysqli_query($mobcon, "INSERT INTO `questions` (`option1`, `option2`, `option3`, `option4`, `correctans`, `question_text`, `cat_id`, `sub_cat_id`, `level_id`, `quesimage`) VALUES ('" . $row['option1'] . "', '" . $row['option2'] . "', '" . $row['option3'] . "','" . $row['option4'] . "','" . $row['correctans'] . "','" . $row['question_text'] . "','" . $row['cat_id'] . "','" . $row['sub_cat_id'] . "','" . $row['level_id'] . "','" . $row['quesimage'] . "');");
}

现在,如果我想将值1添加到$ row ['cat_id'] ,我应该在代码中更改它?我试图使用变量但它不起作用。感谢

0 个答案:

没有答案