• Resolved Zairous

    (@zairous)


    Hi,
    I am wondering how to get te rows numbers of every table and sum them all together then display the result on a page?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    The number of rows can be shown via the [table-info] Shortcode, like
    [table-info id=123 field=number_rows format=raw /]
    (If you remove the format=raw, the header and footer row (if any) will also be counted in the total.

    Unfortunately, TablePress can not sum several row numbers together 🙁

    Regards,
    Tobias

    Thread Starter Zairous

    (@zairous)

    Is there is a function that can sum it?
    Or a function to show the table rows rather than the shortcode
    Or a function that can move from one table id to another
    Specially if it starts with a letter

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no, there’s no direct PHP function for this. For that, I suggest to just have a look at the source code of the shortcode_table_info() function in the controllers/controller-frontend.php file.

    Regards,
    Tobias

    Thread Starter Zairous

    (@zairous)

    I see I guess I will sum the whole post type, what is the metadata used for rows number?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    there’s no meta data for it, it’s calculated directly from the table data array.

    Regards,
    Tobias

    Thread Starter Zairous

    (@zairous)

    so the number or rows is not stored somewhere in the database?
    that would exhaust the database to count all the rows of tablepress post type
    can I create a post meta or custom field and use that shortcode on it? however replacing the id with the current tablepress id? as a variable I mean

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    sorry, that’s beyond what I can help with 🙁

    You can certainly create your own post meta fields, but you will have to take precautions that they are updated when someone changes the table structure (e.g. adds or removes rows).

    Regards,
    Tobias

    Thread Starter Zairous

    (@zairous)

    well the only problem right now is how can I replace the talbe ID with a variable that changes with every table, any idea on that?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no, sorry. 🙁

    Regards,
    Tobias

    Thread Starter Zairous

    (@zairous)

    Thank you sir ^_^

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem!

    Best wishes,
    Tobias

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Query and sum the number of all rows’ is closed to new replies.