Thanks
I tried this.
Code: Select all
$countUnits = "SELECT count(*) FROM students_units WHERE username = '$myusername'";
$result = mysql_query($countUnits);
echo $result;Moderator: General Moderators
Code: Select all
$countUnits = "SELECT count(*) FROM students_units WHERE username = '$myusername'";
$result = mysql_query($countUnits);
echo $result;Code: Select all
<?php
$countUnits = "SELECT count(*) FROM students_units WHERE username = '$myusername'";
$result = mysql_query($countUnits);
$total = mysql_result($result, 0, 0);
echo $total;
?>Since i use mysql_fetch_assoc to retrieve a row from the resultset into an associative array i use an alias for the count(*) column...ianhull wrote:How can I get the numbe of the results using count?
Thanks
I tried this.
Code: Select all
$countUnits = "SELECT count(*) FROM students_units WHERE username = '$myusername'"; $result = mysql_query($countUnits); echo $result;
ianhull wrote:How can I get the numbe of the results using count?
Thanks
I tried this.
Code: Select all
$countUnits = "SELECT count(*) FROM students_units WHERE username = '$myusername'"; $result = mysql_query($countUnits); echo $result;
Code: Select all
$countUnits = "SELECT count(*) as count_students_units FROM students_units WHERE username = '$myusername'";
$result = mysql_query($countUnits);
$result_array = mysql_fetch_array($result);
$count_students_units = $result_array['count_students_units'];
Code: Select all
<?php
$sql = "SELECT * FROM students_units WHERE username = '$myusername'";
if (!$result = mysql_query($sql))
{
die(mysql_error());
}
$row_count = mysql_num_rows($result);
echo $row_count;
?>Code: Select all
<?php
$sql = "SELECT count(*) AS row_count FROM students_units WHERE username = '$myusername'";
if (!$result = mysql_query($sql))
{
die(mysql_error());
}
$row = mysql_fetch_assoc($result);
$row_count = $row['row_count'];
echo $row_count;
?>