Re: Re: question about columns in a table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In message <30186.40440.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>, sudhakar
<finals27@xxxxxxxxx> writes
>I tried with the + sign following was the message=
>"Resource id #3"
>
>The page does not show the numeric figure. please
>advice how to go about with this.

You previously posted
$count="SELECT aboutus + contactus FROM visits";
mysql_query($count);

It sounds like you have "echo mysql_query($count)"

$count="SELECT aboutus + contactus FROM visits";
$res=mysql_query($count);
echo $res[0];


Or perhaps a little easier to understand:
$count="SELECT aboutus + contactus as totalvisits FROM visits";
$result=mysql_query($count);
echo $result['totalvisits'];


>
>--- Pete <cgrp@xxxxxxxxxxxx> wrote:
>
>> In message <fglirt+bu5a@xxxxxxxxxxx>, Sudhakar
>> <finals27@xxxxxxxxx>
>> writes
>> >as suggested not to create a field which would add
>> the numeric 
>> >values in the tables, i used the select sum query
>> however it does 
>> >not work.
>> >The table has 2 fields defined as aboutus &
>> contactus as integer. In 
>> >this case as i will be updating the columns every
>> time there is a 
>> >visit, this table will only have 1 row at all
>> times. Is it because 
>> >of this the query is not being executed.
>> >
>> >$count="SELECT SUM(aboutus, contactus) FROM
>> visits"; 
>> 
>> SELECT aboutus + contactus FROM visits;
>> 
>> If you think of it like a spreadsheet, SUM works
>> *down* the columns, and
>> you need '+' to go across.

-- 
Pete Clark

Sunny Andalucia
http://hotcosta.com/Andalucia.Spain

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux