[英]How do i write this SQL query in PHP and store the value in an array call $query
How do I write the following in php.我如何在 php.ini 中编写以下内容? I want to just drop the array into a variable called $query.我只想将数组放入一个名为 $query 的变量中。 I am very new to this.我对此很陌生。
SELECT name, COUNT(*) as frequency
FROM name_table
GROUP BY name
ORDER BY COUNT(*) DESC
LIMIT 25;
You need to send this query to your database using database driver like mysqli or PDO.您需要使用 mysqli 或 PDO 等数据库驱动程序将此查询发送到您的数据库。
$stmt = $pdo->query('SELECT name FROM users');
while ($row = $stmt->fetch())
{
echo $row['name'] . "\n";
}
Here is PDO documentation: http://php.net/manual/en/book.pdo.php这是 PDO 文档: http : //php.net/manual/en/book.pdo.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.