Hello,
I'm not familiar with php but I need to use a computed field. Would somebody help?
What I need is to go through all database records of a field, check which of them have specific value, count them and subtract them from a constant value.
for example I've got two nodes:
- a single node which contains the constant which is CCK field, integer and is 5.
- and multiple nodes that have a CCK field labeled "are you..." and value "yes" or "no", or 1 or 0. (That part is not yet ready so you can offer another decision). Lets say I've got 3 "yes" values.
I should compute a CCK computed field in the first node and the code should count the total number of "yes" values from the second node type and subtract it from the constant from the first node.
I would greatly appreciate if somebody helps me!
Comments
...
Which means we can't merely direct you to a solution but we have to give you a complete, tested and debugged code, and then adapt the code, and possibly your drupal, to your specific case.
But I can only give a direction.
You want to count the number of 'yes' fields. I explained here how to select all 'age' fields greater than 21. It shouldn't be hard to turn it into a COUNT statement that counts the fields.
=====
You're actually looking for a 'ticket reservation' system, don't you?
Interestingly, there's a 'views_bookmark' module that lets you put a checkbox on the node form, and it manages the counting. However, it doens't suit you becuase the checkbox isn't associated with the node's author but with the user viewing the page. I mention this in the hope that users reading this know of similar modules that may help you out-of-the-box.
Hello, mooffie and thanks
Hello, mooffie and thanks for your help!
What I need to accomplish is a submission form for scholarship and regular students for a course. Those with scholarship provide a code to authenticate it. I use dependent field which asks "are you scholarship student" and if yes is selected then the student is provided a text field to write his code.
But it is important for the system to shows how much of the submissions are regular and how much are scholarship students. Of course somebody can do this by hand but I didn't consider it is so tough to be done. As you can see I'm new to Drupal and I don't know if there is a way to go through all particular CCK fields of specific node type and count the number of yes values. That means that views_bookmar can't do the job because it's a simple checkbox that user selects and cannot be verified with a code.
I really can't understand much of the code you pointed me at and I'd be truly helpful if you can help me a bit more.
By the way I'm a graphic designer, so please excuse me for not having much SQL and PHP knowledge.