我正在尝试将CONCAT
新数据添加到文本字段中的现有数据,并且它可以正常工作,但是日期(我通过日期添加的日期('d-m-Y')是重复的。
我有这个:
$insert_query = "UPDATE `event_registrations` SET
`changereqhistory` = CONCAT_WS('\n','$addition',`changereqhistory`)
WHERE `guid` = '$GUID'";
正如您所看到的,我正在尝试连接现有字段“changereqhistory”的$ addition。 $ addition定义为:
$addition = date('d.m.Y H:i')." - ".$_SESSION['myusername']." | ".$changereq;
和$changereq
只是一个帖子值。
我得到的是这样的:
18.12.2013 16:31 - myusername@mydomain.com |
18.12.2013 16:31 - myusername@mydomain.com | More posted text to be added
18.12.2013 16:31 - myusername@mydomain.com |
18.12.2013 16:31 - myusername@mydomain.com | Posted text to be added
虽然我应该得到这个:
18.12.2013 16:31 - myusername@mydomain.com | More posted text to be added
18.12.2013 16:31 - myusername@mydomain.com | Posted text to be added
为什么在添加发布的文本后,添加了另一个新的“空”行(使用日期时间,用户名和“|”但没有文本)...?
感谢您的帮助。
保存完整代码:
$changereqhistory = mysql_real_escape_string($_POST['changereqhistory']);
$changereq = mysql_real_escape_string($_POST['changereq']);
$addition = date('d.m.Y H:i')." - ".$_SESSION['myusername']." | ".$changereq;
//let's create the query
if ($GUID == $guidrow['guid']) {
$insert_query = "UPDATE `event_registrations` SET
`changereqhistory` = CONCAT_WS('\n','$addition',`changereqhistory`)
WHERE `guid` = '$GUID'";
}
//run the query
mysql_query($insert_query);
显示的代码:
<tr>
<td colspan="2">Change Request History:<br><textarea name="changereqhistory" readonly="readonly" style="width:100%; height:300px;border:1px solid #666666;font-size:11px"><?php echo $guidrow['changereqhistory'];?></textarea>
<textarea id="changereq" name="changereq" rows="3"></textarea><br>Write your notes here ↑
</td>
</tr>