Create Page with PHP scripting
See <a href=”
http://wordpress.org/support/topic/43916#post-245661“>this post for some sample code.
OK, I’ll have to code the template – should be fun for a non-PHP person.
If I have username/password/server values, can I connect to a non-MySQL database as well?
i think you mean to execute php over the admin “write page” thingie..
there are plugins out who can do that for you, since modifying the template would apply the PHP code to ALL pages and i guess you only want it on a single specific page, created in admin interface.
I am using the plugin RunPHP from NoStatusQuo. With it enabled you can use BBCode-like markup to run php code in that page/post .. etc.
Check it out: http://www.nosq.com/2004/10/runphp-wordpress-plugin/
RaulTBC: yes, you can connect to a different MySQL database manually using the
mysql_connect()function from PHP.
RunPHP doesn’t work for me..and I would rather not use it. How do I add new template files and call them from the index page?
Add the template files to the theme directory, and check out this page for details.
I checked out that page, but I don’t understand how to add the template so it recognizes it when requested. For example, I need to use the existing system and add a function so that when navigate.php is requested it loads it into the wordpress system. I’ve tried this about 20 ways with just including wordpress files to get it to work, but it doesn’t.
Not sure your comment resolves my issue – I want to write a page (I assume whatever is written gets saved to my MySQL database) and when I click on the link for that page (http://www.hostname.com/?page_id=22) the page still presents itself in the theme that I have selected but the content area reads a SQL2K database and displays data from that database.
I saw EZ-SQL and have tried to put PHP code in the page data but the PHP code is displayed not executed.
twhite56, you would make the navigate.php page, and put it into your current theme folder. Then you would add this PHP code to the part of the other tempate where you want that navigate.php code to be included:
<?php include (TEMPLATEPATH . ‘/navigate.php’); ?>
So, perhaps in your header.php file or sidebar.php file would be where to put that line. I hope this helps…?
RaulTBC: you cannot embed PHP directly into Pages without use a plugin, like RunPHP linked above.
Alternately, you can create a Page Template for your navigation page. The template file can contain all the PHP you want, including the bit to connect to your other SQL database. Please read “creating your own page template” for details.
The ezSQL included with WordPress is pretty MySQL-specific. You’re better off using the raw PHP SQL functions.
Trevorturk, OK, but here is the issue with my problem – what if I wanted to use navigate.php but just have the header/wordpress functions included? In other words, how do I create a blank index.php page that basically includes the wordpress functions but uses navigate.php.
What I had to do was create a template that had the page-specific SQL to run against the MS-SQL database. I then utilized the ezSQL interface to accomplish the connection. Kludgy, but it worked.
Hopefully someone will treat this issue in the future.
Thanks all for your suggestions.
- The topic ‘Create Page with PHP scripting’ is closed to new replies.