Forums

Nbr of subscribers in front end

SPABO 26 Feb, 2013
Hi Bob,
As you may recall I have a custom code to count the nbr of subscribers.

But is it possible to pull this figure when a date is selected in the frontend?
This is teh HTML code
<div class="ccms_form_element cfdiv_select" id="datum_container_div"><label for="datum">Wedstrijddatum</label><select size="1" id="datum" class="" title="Vul hier uw keuze in." name="datum">
<option value="27-10-2013">27-10-2013</option>
<option value="27-11-2013">27-11-2013</option>
<option value="27-12-2013">27-12-2013</option>
</select>
<div title="Wedstrijddatum" rel="Kies de gewenste datum!" class="tooltipimg"><a href="#">?</a></div><div class="clear"></div><div id="error-message-datum"></div></div>


This is the Custom Code ( before e-mails)
<?
$db =& JFactory::getDBO();
$pst = "SELECT COUNT(*) AS %s FROM %s
  WHERE %s = %s";
$query = sprintf(
  $pst,
  $db->nameQuote('items'),
  $db->nameQuote('J25_chronoforms_data_MYTABLE'),
  $db->nameQuote('datum'),
  $db->Quote(JRequest::getString('datum')));
$db->setQuery($query);
$result = $db->loadObject();
$total = $result->items+1;
$form->data['total'] = $total;
?>


Look forward hearing from you again,

Rgds
K
GreyHead 26 Feb, 2013
Hi SPABO,

It should work OK but you'll need to make sure that the date formats match exactly. Check to see what format is stored in the DB table.

Bob
SPABO 26 Feb, 2013
Bob,
It works fine AFTER submitting...

But I was looking for this nbr {total} in the form BEFORE submitting.

Can I put the Php Code directly in the HTML code :?
GreyHead 26 Feb, 2013
Hi SPABO,

If you want to do this when the user changes the date selection then you'd either need to pre-load all the possible answers (if there are only three this is easy enough) and use JavaScript to select and show the correct one; or you use AJAX to send a query back to the server to get the value for the current selection.

Bob
SPABO 26 Feb, 2013
Hi Bob,
I'm having app 25 forms, and everyform has app. 10-12 dates to select from,
So, for those who are anxious to know how many alreay subscribed, they can check with the list of current subscribers (you helped me to create such)

In other words, case closed and sorry for bothering yoy

Kind regards,
K
This topic is locked and no more replies can be posted.