Support » Plugin: Allow PHP in Posts and Pages » Can't get php to echo a HTML table.

  • I looked through all of the posts here and found only one post dealing with HTML tables but I still cannot get it to work for me. The other post says that if the advanced filter is not used then the table code has to be enclosed in square brackets.

    Since I couldn’t get my actual code to work I created a test page and entered the following code, which did not work. I tried using the Advanced filter and used code like this:

    [php]
    echo "<table width="600" cellpadding="6">";
    echo "<tr>";
    echo "<td>";
    echo "I am trying to create a table.";
    echo "</td>";
    echo "<td>";
    echo "Did it create the table?";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    [/php]

    That didn’t work so I turned off the Advanced filter and tried using square brackets. I am not sure where the square brackets go since the other post did not give an example but I tried it in a couple of different ways. First like this:

    [php]
    echo "[<table width="600" cellpadding="6">]";
    echo "[<tr>]";
    echo "[<td>]";
    echo "I am trying to create a table.";
    echo "[</td>]";
    echo "[<td>]";
    echo "Did it create the table?";
    echo "[</td>]";
    echo "[</tr>]";
    echo "[</table>]";
    [/php]

    and then like this:

    [php]
    echo ["<table width="600" cellpadding="6">"];
    echo ["<tr>"];
    echo ["<td>"];
    echo "I am trying to create a table.";
    echo ["</td>"];
    echo ["<td>"];
    echo ["Did it create the table?"];
    echo ["</td>"];
    echo ["</tr>"];
    echo ["</table>"];
    [/php]

    I could not get it to work in either format. Can someone give me an code example to see where I am going wrong here? I’ve been playing around with this for 4 days now.

    Thanks

    https://wordpress.org/plugins/allow-php-in-posts-and-pages/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Please ignore this post. I am now using a different plugin which works great and uses normal php code such as:

    echo “<table><tr><td>”;
    echo “This is some text.”;
    echo “</td><tr><table”;

    douffle – what plug in did you switch to?

    I switched to a plugin called “Insert PHP”. It worked great for me and I still use it. I never found any php code that would not work with Insert PHP.

    Try it!

    Hi Douffle.

    I have been tearing my hair out trying to do the same thing you’ve been doing, so I’m glad that I’m not alone.
    I am also using Plugin Insert PHP, but I’ve found that the “normal” echo doesn’t seem to be working.
    e.g. This isn’t working for me.
    echo “<table border=1>
    <tr>
    <th>Home Team</th>
    <th>Away Team</th>
    <th>Match date – Time </th>
    </tr>”;

    Could you please provide me with some example close that you have used that does?

    Thanks in Advance.
    Mike.

    Sorry, is supposed to say:
    Could you please provide me with some example code that you have used that does work?

    Hi, a quick update to my comment above.
    I have now found that I AM getting some output from the above code, but for some reason it appears right at the bottom of the page under the footer!
    Any ideas on how to get around that please?

    Hi Douffle.

    I have managed to sort out my error thanks, I had not closed off the table and now it’s working fine.
    Thanks anyway.

    Regards.
    Mike.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Can't get php to echo a HTML table.’ is closed to new replies.