は、いくつかのedits--
I WOUを作っ言語に精通していない人にとっては、2つの異なるアクションで簡単に行うことをお勧めします。試してみることができます
select pollComment ,count(*) as count from students group by pollComment
これはあなたが望んでいる場合は、各IDのカウントを得ることができます。 1つのIDのカウントを取得したい場合は、WHERE句を追加します。
select pollComment ,count(*) as count from students group by pollComment where pollid='$pollid';
次に、しようとしているように2番目のクエリで更新できます。ここで
あなたは、私が
<?php
$query = "select pollComment ,count(*) as count from polls where pollid='$pollid' group by pollComment ;"
if ($result = mysqli_query($conn, $query)) {
/* fetch associative array */
while ($row = mysqli_fetch_assoc($result))
{
$count = $row['count'];
$update = "UPDATE polls SET PollCommentCount = '$count' WHERE id = '$pollid'";
if ($result = mysqli_query($conn, $update)) {
/* fetch associative array */
while ($row = mysqli_fetch_assoc($result)) {
}}
}
/* free result set */
mysqli_free_result($result);
}
?>
は、あなたが何かを試してみましたと信じて、全体として何を探しているのですか? MySQLに 'count'という関数があります。なぜPHPタグが追加されたのか分かりませんが、私はそれを削除するように投票しました。 – IsThisJavascript
試したクエリの例を表示してください。私たちにあなたを助ける何かを与えてください。 –
@RobertDickey、私は試みたコードを追加しました。 – JRK