Title: Use value from php
Last modified: October 31, 2018

---

# Use value from php

 *  Resolved [erwant](https://wordpress.org/support/users/erwant/)
 * (@erwant)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/)
 * Hello,
 * I display a value in B1 cell using php code like this :
    <?php global $nbrepersonnes;
   echo $nbrepersonnes; ?> where nombrepersonnes is equal to 4 for example.
 * I can display it but when I use it in D1 for example I get the following comment
   in D1 (D1 = B1 * 4)
    !ERROR! B1 does not contain a number or expression
 * How is it possible to use a value from a php code in other cells ?
 * Thank you

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/#post-10837234)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * The problem here is that the formulas are evaluated before the PHP code. Thus,
   the formula sees the code and not the number. To achieve that, you would have
   to modify the filter hook in the PHP in Tables Extension, so that it e.g. runs
   on the array values of the tablepress_table_raw_render_data hook, defined here:
   [https://github.com/TobiasBg/TablePress/blob/master/classes/class-render.php#L119](https://github.com/TobiasBg/TablePress/blob/master/classes/class-render.php#L119)
 * Regards,
    Tobias
 *  Thread Starter [erwant](https://wordpress.org/support/users/erwant/)
 * (@erwant)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/#post-10839614)
 * Hi thank you ,
 * could you just help me to understand where are the PHP table extension.
 * Thank you
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/#post-10840548)
 * Hi,
 * the Extension that you are already using to display a value: [https://tablepress.org/extensions/php-in-tables/](https://tablepress.org/extensions/php-in-tables/)
 * Regards,
    Tobias
 *  Thread Starter [erwant](https://wordpress.org/support/users/erwant/)
 * (@erwant)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/#post-10843268)
 * Hi Tobias, I tried tout solution but can’t find the way to make it work.
    Could
   you please help me a little bit more ?
 * Thank you very much
 * Erwan
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/#post-10845023)
 * Hi,
 * unfortunately, I’m very busy and don’t have the time to develop the full solution
   for you.
    If you check the source code of the PHP in Tables Extension, you will
   see that it runs on every cell via the `tablepress_cell_content` filter hook.
 * You should change that, so that it runs on every cells of the `$table['data']`
   array that you get when instead hooking into the `tablepress_table_raw_render_data`
   filter hook.
 * Regards,
    Tobias
 *  Thread Starter [erwant](https://wordpress.org/support/users/erwant/)
 * (@erwant)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/#post-10846696)
 * Thank you Tobias,
 * This is what I did, but it doesn’t work. 🙁
    I replaced tablepress_cell_content
   by tablepress_table_raw_render_data in TablePress Extension file: tablepress-
   PHP-in-tables.php I understand that this will execute php in table extension 
   when $this->table = apply_filters( ‘tablepress_table_raw_render_data’, $this-
   >table, $this->render_options ); is called but when I do that, save table in 
   backend office and then update my website page it doesn’t display anything.
 * The fact is this feature is really important for me, I am blocked in finding 
   a solution for what I want to do. I understand that you are very busy in pluggin
   development, but could I have your help so I can go ahead on my project.
 * Thank you very much
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/#post-10846813)
 * Hi,
 * just changing that filter is not sufficient. The `tablepress_table_raw_render_data`
   hook gives you an array, while `tablepress_cell_content` gives you a string. 
   You will need to add an intermediate function that loops through the array cells
   and call the original function on those.
 * Regards,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Use value from php’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [7 years, 6 months ago](https://wordpress.org/support/topic/use-value-from-php/#post-10846813)
 * Status: resolved