Hi,
thanks for your post, and sorry for the trouble.
As these are the English-language forums, I’ll reply in English, so that more people can benefit from the discussion. I hope that’s ok.
I assume that you are refering to the TablePress “PHP in tables” Extension here?
Can you then maybe post some of your PHP code that you have in the table cells?
Regards,
Tobias
Hi Tobias,
oh yes you’re right. Where I can edit my first post?
Here is my code (simplified):
<?php
/*
Template Name: Konf
*/
?>
<?php
$countobject1 = $_POST['object1'];
if ($countobject1 == ''){
$countobject1 = '1';
}
$countobject2 = $_POST['object2'];
if ($countobject2 == ''){
$countobject2 = '1';
}
$count_offn = $countobject1 + $countobject2;
?>
.... etc. ...
After that I get the page content (table via tablepress and the php extension). Within this table is written:
<?php echo $count_offn; ?>
In debug mode I get this error:
Notice: Undefined variable: count_offn in /Applications/MAMP/htdocs/XXX/wp-content/plugins/tablepress-php-in-tables/tablepress-php-in-tables.php(26) : eval()'d code on line 1
Cheers & Thx
bbthoms
Hi,
editing your first post is no longer possible, I think. Editing a published post in the forums is only allowed for up to an hour or so.
Ok, so in the table, the PHP code is
<?php echo $count_offn; ?>
At that location, you will need to tell PHP to use the global variable, i.e.
<?php echo $GLOBALS['count_offn']; ?>
or (if you prefer that syntax)
<?php global $count_offn; echo $count_offn; ?>
Regards,
Tobias
Hi Tobias,
thank you for the fast reply. I tried the global but in the template file. Obviously it was the wrong place.
Thank you very much!
Cheers
bb
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Best wishes,
Tobias
P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!