PHP code in table cells
-
can you provide an example of using this plugin?
-
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,
Tobiasthat 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*\
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,
TobiasTY. 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.
Hi,
ah, ok 🙂 But still don’t do it 🙂
Regards,
Tobias
The topic ‘PHP code in table cells’ is closed to new replies.