0

I have a node type called Statistics. I then would like to create a Statistics node called package 1 which will hold data similar to below.

Contributor Level
Points needed | Level
1             | Beginner
5             | Intermediate
10            | Expert

Participator Level
Points needed | Level
1             | Beginner
15            | Intermediate
25            | Expert

I would then like to call the level of fetch the level based on points. So if it was an sql statement the query would be similar to.

$table = //fetch table based on criteria;
$points = //points based on users actions;
$level = 'select Level from $table where points = $points';
return $level;

However, I dont see a suitable way to create a table through the node create from on drupal, only through html. As a result I would have to create a php statement for each line on each table I create similar to

 if ( $points = 1 ) { 
    return "beginner" 
 } elseif ( $points > 1 & <= 5 ) 
    return "intermediate"
 } //etc

which will take a really long time.

So I was just wondering how I could essentially create a node field which can hold data which can be out put as a variable.

3
  • Sorry, having trouble following your question here. You can't create a SQL table from a node form with an out-of-the-box content type. You can add a field to your node type (for instance a select box with (Beginner, Intermediate, Expert) as options and then select the appropriate option when creating the node. – Chris Rockwell Aug 1 '13 at 15:53
  • Hi Chris, Sorry I'm confused about what I am asking. Theres two things - 1) I have a variable called $points, 2) I have a series of, tables (not yet on the drupal site) which are like in the question. What I would like is to get the level from the table that matches the points. So I could create a select box like you suggested, but I do not want the user to select an option, I would like it to be auto populated and to update when the points update. – Sam Healey Aug 1 '13 at 16:52
  • Where is the variable $points coming from? – Chris Rockwell Aug 1 '13 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.