Home > Backend Development > PHP Tutorial > php如何向数据库中的某串数据后追加内容【急】

php如何向数据库中的某串数据后追加内容【急】

WBOY
Release: 2016-06-06 20:31:15
Original
1521 people have browsed it

php小白想做个临时用的小工具
php+myspl,SAE 上的。
希望能向某行的tag列里不断追加内容

<code>$sql = "UPDATE tag SET  tag =concat(tag,'$biaoqian') WHERE id = '$xuehao'";
</code>
Copy after login
Copy after login

然后什么用也没有
请问应该怎么写才能实现
我也想过先读取再拼接。。。但是发现自己根本不会读取某行某列的内容ORZ

完整的代码

<code>学号:
<?php echo $_POST["xuehao"]; ?>
<?php echo "<br>"; ?>
tag:<?php echo $_POST["biaoqian"]; ?>
<?php echo "<br>"; ?>


<?php $mysql = new SaeMysql();

$sql = "SELECT * FROM `tag` LIMIT 10";
$data = $mysql->getData( $sql );



$biaoqian = $_POST['biaoqian'];
$xuehao = $_POST['xuehao'];

$sql = "UPDATE tag SET  tag =concat(tag,'$biaoqian') WHERE id = '$xuehao'";


$mysql->runSql($sql);
if ($mysql->errno() != 0)
{
    die("Error:" . $mysql->errmsg());
}

$mysql->closeDb();

echo $mysql->errmsg();   
</code>
Copy after login
Copy after login

回复内容:

php小白想做个临时用的小工具
php+myspl,SAE 上的。
希望能向某行的tag列里不断追加内容

<code>$sql = "UPDATE tag SET  tag =concat(tag,'$biaoqian') WHERE id = '$xuehao'";
</code>
Copy after login
Copy after login

然后什么用也没有
请问应该怎么写才能实现
我也想过先读取再拼接。。。但是发现自己根本不会读取某行某列的内容ORZ

完整的代码

<code>学号:
<?php echo $_POST["xuehao"]; ?>
<?php echo "<br>"; ?>
tag:<?php echo $_POST["biaoqian"]; ?>
<?php echo "<br>"; ?>


<?php $mysql = new SaeMysql();

$sql = "SELECT * FROM `tag` LIMIT 10";
$data = $mysql->getData( $sql );



$biaoqian = $_POST['biaoqian'];
$xuehao = $_POST['xuehao'];

$sql = "UPDATE tag SET  tag =concat(tag,'$biaoqian') WHERE id = '$xuehao'";


$mysql->runSql($sql);
if ($mysql->errno() != 0)
{
    die("Error:" . $mysql->errmsg());
}

$mysql->closeDb();

echo $mysql->errmsg();   
</code>
Copy after login
Copy after login

试下$sql = "UPDATE tag SET tag =concat(tag,'$biaoqian') WHERE id =".$xuehao;

tag列是否为字符串类型,如果是的话理论上是没问题的

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template