This is my query when i run this query in phpmyadmin it retrieve the right results but when i run it in php it gives an that kind of error "Notice: Undefined index: pcat in C:\xampp\htdocs\classified\index.php" . I didn't understand this error because "pcat" is a column in database which defines in query so why this kind of error arise? Please help me
<?php
$query = mysql_query("SELECT COUNT( pcat ) FROM category WHERE pcat = 'Jobs'") or die(mysql_error());
while($getcount = mysql_fetch_array($query)){
?>
<span class="count">(<?php echo $getcount['pcat']; ?>)</span></th>
<?php } ?>
<?php
$query = mysql_query("SELECT COUNT( pcat ) AS pcat_count FROM category WHERE pcat = 'Jobs'") or die(mysql_error());
while($getcount = mysql_fetch_array($query)){
?>
<span class="count">(<?php echo $getcount['pcat_count']; ?>)</span></th>
<?php } ?>
you aren't actually SELECT
ing pcat, rather COUNT(pcat).
edited to add - mysql_* is dangerous and outdated, look at pdo