PHP in Wordpress Posts - Is this okay?
Posted
by Thomas
on Stack Overflow
See other posts from Stack Overflow
or by Thomas
Published on 2010-05-24T19:44:39Z
Indexed on
2010/05/24
19:51 UTC
Read the original article
Hit count: 303
I've been working with some long lists of information and I've come up with a good way to post it in various formats on my wordpress blog posts.
I installed the exec-PHP plugin, which allows you to run php in posts. I then created a new table (NEWTABLE) in my wordpress database and filled that table with names, scores, and other stuff.
I was then able to use some pretty simple code to display the information in a wordpress post. Below is an example, but you could really do whatever you wanted. My question is - is there a problem with doing this? with security? or memory? I could just type out all the information in each post, but this is really much nicer. Any thoughts are appreciated.
<?php
$theResult = mysql_query("SELECT * FROM NEWTABLE WHERE Score < 100 ORDER BY LastName");
while($row = mysql_fetch_array($theResult))
{
echo $row['FirstName'];
echo " " . $row['LastName'];
echo " " . $row['Score'];
echo "<br />";
}
?>
© Stack Overflow or respective owner