Jump to content

[SOLVED] Counting records


DrTrans

Recommended Posts

Heres my code

 

<?php 
    
    $connect = mysql_connect("localhost","damgears_evil","damgears");
     mysql_select_db("damgears_evil");
     $queryreg = mysql_query("COUNT (*) FROM titles");
   
    
    ?>
    
    <p align="center">There have been <?php echo"$amountitles"; ?> set with our Titler.</td>

 

 

Link to comment
Share on other sites

a.) I believe COUNT cannot be used like that and you should infact use SELECT COUNT.

b.) At no point in your code do you seem to set $amounttitles to any value.

 

mysql_query always returns a resource object even if logically you know it will just be one value. You will need to use $row= mysql_fetch_array($queryreg); and $amounttitles = $row[0];

Link to comment
Share on other sites

From my interpretation of your first post, I think you are saying there will be multiple records with the same 'skey' value and want to know how many times each one appears. If that is the case you will need something a little different:

 

SELECT skey, COUNT(skey) as count
FROM titles
GROUP BY skey

 

That will return a separate record for each unique value along with the number of times it appears.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.