Cannibal_Monkey Posted September 28, 2006 Share Posted September 28, 2006 I have a row C of several numbers. I want to add all the numbers of that row and create a new variable. I have this for that line of code "$e = mysql_query('SELECT SUM `c` FROM `b`');" If it's wrong what do I do? I've searched around and couldn't find the answer. Quote Link to comment https://forums.phpfreaks.com/topic/22430-adding-numbers-in-row/ Share on other sites More sharing options...
HuggieBear Posted September 28, 2006 Share Posted September 28, 2006 It's almost right:[code]<?php$sql = "SELECT SUM(c) as total FROM tablename";$result = mysql_query($sql);$row = mysql_fetch_row($result);echo "The total is {$row['total']}";?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22430-adding-numbers-in-row/#findComment-100559 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.