Select ALL, but count only certain titles
Posted: Wed Sep 23, 2009 3:44 am
Can someone tell me what on earth I am doing wrong here please?
Firstly I am getting this error:
The database has two row of entries. One for one Title and one for a different Title.
It's basically doing a count of everything producing the different titles, but showing "2" for both.
S.
Code: Select all
include "dbconn.php";
if ($update == "delete") {
$query = mysql_query ("delete FROM stocknotification where title = $title");
echo "<div class='admincompletedbox'>
<b>That comment was deleted.</b></div>";
}
echo "<table width='715' cellpadding='1' cellspacing='0' class='table' bordercolor='#FFFFFF' border='1' style='border-collapse: collapse;'>";
$resultcat = mysql_query ("SELECT DISTINCT title FROM stocknotification ORDER BY title");
if (mysql_num_rows($resultcat)==0)
{
echo "<tr><td><div class='sectionhead'>No one has yet posted a comment..</div></td></tr>";
}
else
{
while ($rowcat = mysql_fetch_object($resultcat))
{
echo "<tr><td colspan='2'><div class='sectionadminhead'>$rowcat->title</div></td></tr>";
$result = mysql_query ("SELECT * COUNT (title) as num_of FROM stocknotification WHERE title = '$rowcat->title'");
echo "<tr><td>";
echo $row['num_of'] ." have registered for this product.";
echo"</td><td>
</td>
</tr>";
}
mysql_free_result($result);
}
mysql_free_result($resultcat);
mysql_close($sqlconn);
echo "</table>";The line in question isWarning: mysql_free_result(): 5 is not a valid MySQL result resource in /usr/local/psa/home/vhosts/shop.co.uk/httpdocs/support/includes/notifications.inc on line 53
Code: Select all
mysql_close($sqlconn);It's basically doing a count of everything producing the different titles, but showing "2" for both.
S.