无法回应价值

时间:2011-05-12 05:30:28

标签: php count echo

我只是试图从我的mysql数据库中检索一个值并尝试使用php函数打印它。但这不起作用:(请帮忙。

<?php
include("connection.php");
$con=mysql_query("SELECT times FROM counts WHERE item='applemenu';");
$info = mysql_fetch_array($con);
$count==$info['times'];
?>

在一些html标签之后

<?php echo $count;?>

有什么不对吗?

3 个答案:

答案 0 :(得分:3)

$count==$info['times'];

将此更改为

$count=$info['times'];

答案 1 :(得分:0)

<?php
 include("connection.php");
 $input = 'applemenu';
 $stmt = mysqli_prepare($con,"SELECT times FROM counts WHERE item=?");
 mysqli_stmt_bind_param($stmt,"s",$input);
 mysqli_stmt_execute($stmt);
 mysqli_stmt_bind_result($stmt, $count);
 mysqli_stmt_fetch($stmt);
 mysqli_stmt_close($stmt);
 mysqli_close($con);

 echo $count;
?>

答案 2 :(得分:0)

<?php
include("connection.php");
$con=mysql_query("SELECT times FROM counts WHERE item='applemenu';");
$info = mysql_fetch_array($con);
$count= $info['times'];// This was the wrong with == operator
?>

在一些html标签之后

<?php echo '$count';?>