Buy Now
Sign in

Count how many entry in table

Qbik , September 01 2011
Q
Qbik
I know that this is easy but maybe someone can make it in easier way

in footer i add this
<p style="padding-top:10px;">  <?php

  $sql = "SELECT COUNT(cf_id) FROM jos_chronoforms_YourTable;";

  $result = mysql_query($sql);

  if(!$result) {

    $err=mysql_error();

    print $err;

    ob_clean();

    exit();

  }echo("All reservations:". mysql_result($result, 0) . "&nbsp;&nbsp;");

  $sql = "SELECT SUM(cf_id) FROM jos_chronoforms_YourTable;";

  $result = mysql_query($sql);

  if(!$result) {

    $err=mysql_error();

    print $err;

    ob_clean();

    exit();

  }?>


is there any way to chceck this without writing table name?
GreyHead
Hi Qbik,

I don't see how you could do it without writing the table name???

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
?
Q
Qbik
ok and another question about that is there any option to count entry in table in new CC for J2.5?

i can Use my code but where to put it?
admin
Hi Qbik,

Try
count($table_data);
?

This may not be valid in future versions though, a new method may be needed.

Regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
Q
Qbik
Ok great i will try it but can you tell me where to put it?
admin
if it works then it should work in any custom list box, header, body or footer.
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
Q
Qbik
ok but i set Auto Listing to yes so to add this "count" stuff i have to disable it yes?
there is no other option to add this?
admin
Hi Qbik,

Sorry for the late answer, well, you may try to use the "Task Control" to do that, but I'm not sure if it will work, there may be other ways, but they may be testable after the new version hopefully this week, so please contact me again after you install the new version

Regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
V
vales
I added after line 902 of components \ com_chronoconnectivity \ libraries \ chronoconnection.php the statement global $ total

  function list_records($where = '', $first = false, $limited = false, $disable_hierarchies = false){
    global $total;



and you can call in header, body, footer with
<?php
global $ total;
echo $total;
?>


works well
Q
Qbik
ok great but this work only when Auto Listing is set to "no" right?

any solution for Auto Listing set to yes?
admin
Hi,

In the new V4 RC3, I think that you can do it this way:

#1- setup a task control for the "list data", add the form event name which has the "ChronoConnectivity task" action, and add the action's order number (don't configure the task in Chronoforms).

#2- add a "Custom code" action before the "ChronoConnctivity task" and enter the code below:

<?php
$MyConnection =& CFChronoConnection::getInstance("Connection_NAME");
$MyConnection->list_records();
echo $MyConnection->pageNav->total;
?>


That should output the record count above the list.

Regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
?
Q
Qbik
It take me a long time but i tried one more time and i dont know how to set this corectly can You help me with that?
I can send you mine CC - exported table

Or you can write exactly where to write what

E.g. In front editing tab

Ok I understand that I have to add ChronoConnectivity task (but what is that exactly)
List data task control


Can You write me step by step how to set this, thx in advance
admin
Hi Qbik,

There is a simple tutorial on task control on our FAQs page, if its hard, then you may simply run a custom count query on the list page and echo the total result.

Regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!