is there any trick to add the last input as the FIRST input via sql ?

In this example it add the last line at the end of lastline :

mysql_query("UPDATE `mytable` SET `lastline` = concat(lastline, '$lastline') WHERE `id`='$id'");

this is the current order when add values to database :

Line #1\r\n
Line #2\r\n
Line #3\r\n
Line #4\r\n

I want the last line will add first (without read and write the content of lastline) so the progress will be directly on writing the line :

Line #4\r\n
Line #3\r\n
Line #2\r\n
Line #1\r\n

Thanks !

有帮助吗?

解决方案

Sounds like you just need to flip the order of your arguments here...

concat('$lastline', lastline)

Side note: mysql_* methods are deprecated, you should switch to mysqli or PDO as soon as possible. Then look at prepared statements with bound parameters, so you aren't so open to SQL injection.

其他提示

You can simply change sequence in CONCAT:

mysql_query("UPDATE `mytable` SET `lastline` = concat('$lastline', lastline) WHERE `id`='$id'");

P.S. Also escape your variables in query. i.e. with mysql_real_escape_string

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top