greetings earthlings!
How to add the contents of my sql into php?
for example i have table scores: math = 3, english = 2, logic = 3, total = Null
how can i add the 3 columns in php?
adding contents of sql in php
Moderator: General Moderators
Re: adding contents of sql in php
Well, if you insist on doing it in PHP just get the record from the database and add the columns like you'd access anything else... eg
You'd be better off doing the maths in the SQL though.
Code: Select all
$total = $record->maths + $record->english + $record->logic;Re: adding contents of sql in php
Use a simple script to get the data from the MySQL tables into an array (there are lots of tutorials on the net) and then add them.
Do your math in PHP not in MySQL it' s much faster and you don' t load your database.
Do your math in PHP not in MySQL it' s much faster and you don' t load your database.
Re: adding contents of sql in php
That's completely wrong.Rovas wrote:Do your math in PHP not in MySQL it' s much faster and you don' t load your database.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: adding contents of sql in php
It is advisable to put as much in the querying itself as possible, as Onion already mentioned.