如何在php中显示(回显)所选值?

时间:2014-09-22 09:12:12

标签: php echo

如何显示mysql_query中的值或将值保存在变量中?目前我获得资源ID#4。

$currentpointsquery = "SELECT user_points FROM points WHERE user_id = '$user_id';";
$currentpointsquery2 = mysql_query($currentpointsquery);
echo(currentpointsquery2);

2 个答案:

答案 0 :(得分:1)

试一试:

$currentpointsquery = "SELECT user_points FROM points WHERE user_id = '$user_id'";
$currentpointsquery2 = mysql_query($currentpointsquery);
$currentpoints = mysql_fetch_array($currentpointsquery2);
echo $currentpoints['user_points'];

答案 1 :(得分:0)

echo($currentpointsquery2);

在这里,您尝试打印mysql resource variable,而不是它引用的资源中包含的值。 mysql_fetch_array()函数从记录集返回一行作为关联数组和/或数字数组。所以试试

echo $currentpoints[0];

 echo $currentpoints['user_points'];