![]() |
|
#1
|
|||
|
|||
new in this areaCAN ANY ONE HELP ME??
I'M PRETTY NEW IN PHP MYSQL I HAVE ONE TABLE AND IN THE TABLE HAVE 5 COLUMN I WANT TO COUNT THE VALUE OF 4 COLUMN AND THAT WILL SHOW IN ANOTHER COLUMN JAST LIKE THIS : ----------------------------------------- -------ROW1 | R2| R3| R4 | R5----------- ----------------------------------------- ----------1 | 1 | 1 | 1 = 4 < COL1 TOTAL ----------------------------- ----------2 | 2 | 2 | 2 = 8 < COL2 TOTAL ----------------------------------------- ----------------------------------------- ----------3 | 3 | 3 | 3 | 12 < ROW TOTAL PLEASE HELP ME BEST REGURDS |
|
#2
|
|||
|
|||
|
Hi sujon,
Would you be looking for something like this? PHP Code:
That should work, but I might have done something wrong there...perhaps someone better at this stuff can check it for me. __________________
You're not supposed to be looking at this. |
|
#3
|
||||
|
||||
|
Hello sujon,
There are 2 schools of thought on this; there are those that 'work-the-script (PHP)' and then there are those that 'work-the-db (MySQL)'. I prefer the latter... i.e. I prefer to get MySQL to do the dirty work if it can and if it's appropriate for the rest of the script. Conkermaniac's example is a sample of the 'work-the-script'-type solution. Here's one that's 'working-the-db': PHP Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#4
|
|||
|
|||
|
Can further calculations be carried out by using this method ?
In the example PHP Code:
Can I add r1 + r2 + r3 then divide by r4 ? I have tried a number of different ways to get that to work but to no avail. :-( But as usual I will probably be missing a simple piece of code. |
|
#5
|
||||
|
||||
|
Yes it's possible... but you know SQL, one typo in the statement and all hell breaks lose!
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#6
|
|||
|
|||
|
Would I bracket the seperate instructions ie
PHP Code:
or PHP Code:
|
|
#7
|
||||
|
||||
|
The INSERT statement I can suggest (considering everything is set up OK with your table) is:
PHP Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#8
|
|||
|
|||
10q every onehi thanx every one its working fine
|
Recent GIDBlog
Last Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What Search Engines are you listed in? | NetWay | Search Engine Optimization Forum | 6 | 23-Sep-2003 09:53 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The