本文介绍了总喜欢的人数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写一下喜欢的总数,但我不知道怎么能让这个来检索表的内容
Hi, I would like to write, the total number of likes, but I don't know how I can make this to retrieve the contents of the table
<?php try { $user = 'root'; $pass = ''; $PDO = new PDO('mysql:host=localhost;dbname=mike', $user, $pass); $PDO->exec("set names utf8"); $query = "SELECT SUM(likes) as test FROM news WHERE autor=".$_SESSION['id'].""; $c_query = $PDO->prepare($query; $c_query->execute(); $results = $c_query->fetch(PDO::FETCH_ASSOC); if($results) { echo "Total number of likes: ".$f_test = $results['test']; } } catch(PDOException $e) { echo "Error: " .$e; } ?>我的尝试: with COUNT()并使用多个查询
What I have tried: with COUNT() and use multiple query
推荐答案user = ' root'; user = 'root';
pass = ' ' ; pass = '';
PDO = new PDO(' mysql:host = localhost; dbname = mike', PDO = new PDO('mysql:host=localhost;dbname=mike',
更多推荐
总喜欢的人数
发布评论