Title: PHP code in table cells
Last modified: August 30, 2016

---

# PHP code in table cells

 *  Resolved [david.w.stevens](https://wordpress.org/support/users/davidwstevens/)
 * (@davidwstevens)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-code-in-table-cells/)
 * can you provide an example of using this plugin?
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-code-in-table-cells/#post-6823615)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * You could for example use PHP code like
 *     ```
       <?php echo 5+3; ?>
       ```
   
 * in a table cell, when the Extension is activated.
 * Regards,
    Tobias
 *  Thread Starter [david.w.stevens](https://wordpress.org/support/users/davidwstevens/)
 * (@davidwstevens)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-code-in-table-cells/#post-6823705)
 * that did work. But I’m trying to get a record info from a table and display the
   number. Still getting the
 * Parse error: syntax error, unexpected ‘<‘ in /home/stevensd/public_html/atti/
   wp-content/plugins/tablepress-php-in-tables/tablepress-php-in-tables.php(26) :
   eval()’d code on line 1
 * I’m using this code from the admin tab, atti.cochisecs.com :
 * <?php
    $user=” stevensd_wp5″; $password=”b@ck_IN_bl@ck”; $database=”stevensd_wp5″;
   mysql_connect(localhost,$user,$password); @mysql_select_db($database) or die(“
   Unable to select database”); { $query=”SELECT count(*) FROM stevensd_wp5 WHERE
   element_name = 10; $result=mysql_query($query); $name=mysql_result($result,$i,”
   element_name”); if ( $num > 0 ) { echo(“<th>Applications Pending</th>”); echo(“
   <tbody>”); for ($i = 0; $i < $num; $i++) { $name=mysql_result($result,$i,”element_name”);
 *  echo(“<tr>”);
    echo(“<td>$name</td>”); echo(“</tr>”); } } mysql_close(); } else{
   echo “<b>No search entered.</b>”; } ?>
 * I have created an account if you need access
    U: php_helper P: RMdiG8*
 *  Thread Starter [david.w.stevens](https://wordpress.org/support/users/davidwstevens/)
 * (@davidwstevens)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-code-in-table-cells/#post-6823706)
 * \
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-code-in-table-cells/#post-6823740)
 * Hi,
 * first of all, please never, ever post usernames/passwords here in the public 
   forums! Please immediately go change the two passwords that you posted!
 * As for the PHP code: The problem here might be the line breaks in the code, as
   TablePress converts those to HTML `<br />` tags and that’s what’s causing the
   issue. To fix that, please extend the Shortcode that you are using to
 *     ```
       [table id=123 convert_line_breaks=false /]
       ```
   
 * (with the correct table ID).
 * Now, for the PHP code itself: Using that in a table is not really a good idea.
   The code is not only badly written and uses outdated functions, but it’s also
   generating HTML code for a partial table. Sticking that into another table like
   this will certainly break things.
 * Regards,
    Tobias
 *  Thread Starter [david.w.stevens](https://wordpress.org/support/users/davidwstevens/)
 * (@davidwstevens)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-code-in-table-cells/#post-6823745)
 * TY. this site is only a sandbox with fake data. I’m just trying to get some basic
   data from the table and I am new to php coding.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-code-in-table-cells/#post-6823748)
 * Hi,
 * ah, ok 🙂 But still don’t do it 🙂
 * Regards,
    Tobias

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

The topic ‘PHP code in table cells’ 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/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 6 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/php-code-in-table-cells/#post-6823748)
 * Status: resolved