Jump to content

Recommended Posts

Hello friends,

 

let say we have single database table as following

 

it has id and name and hits

i can count id's but how to count hits

 

 

CREATE TABLE `table` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`name` text NOT NULL,
`hits` bigint(20) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`)

INSERT INTO `table` VALUES (1, 'one', 5);
INSERT INTO `table` VALUES (2, 'two', 3);
INSERT INTO `table` VALUES (3, 'three', 6);

 

for ids i use

 

 

$sql = "SELECT COUNT(id) AS totalid FROM table";
$cux = mysql_query($sql) or die($sql);
$counx = mysql_fetch_array($cux);
echo $count['totalid'];

 

 

this will give me ids = 3

 

Now for hits i don't wanna get how many rows but i wanna calculate it so in this example

 

hits = 5+3+6 = 14

 

how can i this in that way !

 

Link to comment
https://forums.phpfreaks.com/topic/197895-to-calculate-this/
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.