Php 用逗号点击计数器
我希望在我的数字中使用逗号,如1234=1234 123456 1234,56等 这是代码Php 用逗号点击计数器,php,mysql,Php,Mysql,我希望在我的数字中使用逗号,如1234=1234 123456 1234,56等 这是代码 <?php //Get current count $result = mysql_query("SELECT counter FROM profiles WHERE username='$username'") or die("Unable to query database ! " . mysql_error()); //Add 1 to the count $count =
<?php
//Get current count
$result = mysql_query("SELECT counter FROM profiles WHERE username='$username'") or
die("Unable to query database ! " . mysql_error());
//Add 1 to the count
$count = mysql_result($result, 0);
$count++;
//Update database with new value
mysql_query("UPDATE profiles SET counter = '$count' WHERE username='$username'") or
die("Unable to insert into database ! " . mysql_error());
?>
显示数字时,您要使用:
number_format($count);
您的代码易受攻击。在将用户输入插入查询之前,请正确转义用户输入。另外,停止使用不推荐的mysql.*
函数,切换到MySQLi/PDO…并查看准备好的语句@user3609581的可能副本:很高兴您找到了问题的解决方案。下次,请在询问之前搜索。你不费吹灰之力就能找到这个问题的解决办法。干杯@用户3609581如果这有助于您解决问题,请接受它,以便将此问题标记为已回答