Jump to content

To Calculate This !


manalnor

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.