我想在$ _POST ['mp']之后添加“Megapixels”这个词,以便在'mp'文本框中输入12,它将为数据库保存12百万像素。
PHP我将传递的'mp'值存储在变量'$ mp'中:
$mp = $cameras->real_escape_string($_POST['mp']);
我试过以下
$mp = $cameras->real_escape_string($_POST['mp'] . "Megapixels");
$mp = $cameras->real_escape_string($_POST['mp']) . "Megapixels";
我确定这很容易做到,我只是遗漏了一些东西。
感谢您的帮助
代码更新:
<?php
if (isset($add)) {
/* GET FROM POST */
$brand = $cameras->real_escape_string($_POST['brand']);
$category = $cameras->real_escape_string($_POST['category']);
$model = $cameras->real_escape_string($_POST['model']);
$mp = $cameras->real_escape_string($_POST['mp']);
/* QUERY */
if (mysqli_query($cameras, "INSERT INTO models(
/* ROW NAME */
brand, category, model, mp
) VALUES(
/* VARIABLE NAME */
'$brand', '$category', '$model', '$mp'
)")) {
header("Location: http://admin.specced.co.uk?suc=3");
}
}
?>
答案 0 :(得分:-1)
在处理$_POST
数组之前尝试更改$ _POST ['mp']的值?
$_POST['mp'].='Megapixels';
$mp = $cameras->real_escape_string( $_POST['mp'] );