Help wanted with PHP arithmetic and mySQL select
Moderator: General Moderators
Help wanted with PHP arithmetic and mySQL select
Hi all,
I have written a photographic gallery script using mySQL and PHP. What I set out to do tonight was to query the DB and discover how many images in total are available for visitors to see.
There isn't a DB entry per image, rather I have a column showing how many images per gallery. For instance, a gallery of photograph on the Tokyo Fish Market has 15 images in it. Another on India has 18 etc etc.
What I wanted to do was select each of these values (the column data type in mySQL is INT) and total them. I thought it would be quite easy but I must admit to now being stumped.
Any help greatly appreciated.
Jon
I have written a photographic gallery script using mySQL and PHP. What I set out to do tonight was to query the DB and discover how many images in total are available for visitors to see.
There isn't a DB entry per image, rather I have a column showing how many images per gallery. For instance, a gallery of photograph on the Tokyo Fish Market has 15 images in it. Another on India has 18 etc etc.
What I wanted to do was select each of these values (the column data type in mySQL is INT) and total them. I thought it would be quite easy but I must admit to now being stumped.
Any help greatly appreciated.
Jon
Almost there I think
Probably sounds stupid, but now I am getting Resource ID#9 after running your SELECT suggestion..
How do I turn the fetched result into a usable variable?
Jon
How do I turn the fetched result into a usable variable?
Jon
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
go to the manual http://www.php.net/mysql
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
One of the best resources to learn is to hack the Example codes that are in the manual... And the contribution notes of the user in the bottom.
check them.. you'll figure it out.. if not, show us your code.. but i see you have to use http://www.php.net/manual/en/function.m ... -array.php
check them.. you'll figure it out.. if not, show us your code.. but i see you have to use http://www.php.net/manual/en/function.m ... -array.php