How to count entries?
-
Hi,
I made a custom PDF template and I need to output receipt number, which should be a number of each entry.
This is the code example:
<?php foreach ($lead_ids as $lead_id) { $lead = RGFormsModel::get_lead($lead_id); $form_data = GFPDFEntryDetail::lead_detail_grid_array($form, $lead); global $wpdb; $leadId = $wpdb->get_row($wpdb->prepare( " SELECT COUNT(*) AS leadId FROM <code>" . $wpdb->prefix . "rg_lead</code> WHERE form_id=%d AND id <= %d", $form_data['form_id'], $form_data['entry_id'] ), ARRAY_A); $receipt_out = $leadId['leadId'] + 80; PDF_Common::view_data($form_data); ?> <p>Receipt / Reçu: <?= sprintf("A%'.05d\n", $receipt_out) ?></p> <?php } ?>
now the above code works fine, but it only counts to the number 5. If I have more then 5 entries then each next entry will have receipt number 5 while it should continue the counting 6,7,8,…
Can you help me with this?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to count entries?’ is closed to new replies.