Webform : how to count and live display results Update

webform_get_submission_count isn't precise enough (we need to count into submissions)

but

&lt;?php
if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load($nid);
  if ($node-&gt;type == 'webform') {
    $count = db_result(db_query('SELECT count(*) FROM {webform_submissions} WHERE nid = %d', $nid));
    $atelier_1 = "sources" ;
    $sql = "SELECT count(*) FROM {webform_submitted_data} WHERE data LIKE \"".$atelier_1."\" ;";
    $count_atel_1 = db_result(db_query($sql));
  }
}
echo $sql;
echo $count_atel_1;
?&gt;

This webform has been submitted &lt;?php print $count ?&gt; times.


looks ok

end update-------------------

We'd like to use a webform so that our students should register on some workshops.

The webform works great. Now we'd like to display live the number of students that are already register in on of the workshops so that the other should know if there remains some possibilities of registration (each workshop can only accept 20 students at the same time)

I'm trying with that that doesn't work ($atelier_1 = "sources" ;) is the name of one workshop :

&lt;?php
if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load($nid);
  if ($node-&gt;type == 'webform') {
    $count = db_result(db_query('SELECT count(*) FROM {webform_submissions} WHERE nid = %d', $nid));
    $atelier_1 = "sources" ;
    $count_atel_1 = db_result(db_query('SELECT count(*) FROM {webform_submitted_data} WHERE data LIKE %d', $atelier_1');
  }
}

echo $count_atel_1;
?&gt;


Any help or suggestion welcome
I looked through the Drupal document from drupalcontrib.org and i saw that there is webform_get_submission_count function to get a count of the total number of submissions for a node. I think you can use that function instead by create a new one.