Hello,
I'm working on a little project on a development site (Drupal 4.7.4 / MySQL 4.1.20) that needs to be rolled out to the production site ASAP.
I need a little help inserting some PHP/SQL code into a page that will query the database and pull out an integer which will then be displayed on the page.
I've managed to figure out the actual SQL needed to do this by querying the database manually via a Terminal window. Through a process of trial and error I came up with the following statement:
select sum(field_number_of_students_involv_value) from node_content_cck_test;
The code above does exactly what I want (albeit from a Terminal window) it returns the accurate total of a number of database fields added together. I just need a final bit of help integrating the above line of SQL into drupal-friendly PHP which returns to the page something like:
Total number of students enaged in all activities to date = (the returned integer).
I've tried and can't figure it out so far : (
More background information here: http://drupal.org/node/93707 (I decided to create this new post as the title of the old one didn't really describe my problem anymore). I'll create a link from the old post to this one so that people can follow up if there are replies to this post.
Any help would be really appreciated.
Thanks
Jay
Comments
quick guess..
Would it be something like this?
I haven't tested it, but, it's a variation of another snippet here that displays the number of books in the database
Phil
Example Snippet
You'll need to add something like the following to your page with PHP parsing enabled:
--
Nathan Rambeck
Yes!
Big thank you to PhilK and nrambeck for the help.
I tried both snippets and found nrambeck's to do exactly what I wanted straight away.
The input you have both given to my problem is very much appreciated : )
All the best
Jay
The Centre for Sustainable Futures ~ http://csf.plymouth.ac.uk