WordPress.org

Ready to get started?Download WordPress

Forums

Create Page with PHP scripting (15 posts)

  1. RaulTBC
    Member
    Posted 8 years ago #

    Is it possible to create a page that has the PHP scripting in it to call a database and retrieve dynamic data from it? I want to retrieve dynamic data from a static page link. Or is it better to create my own php page and link to that?

  2. skippy
    Member
    Posted 8 years ago #

    Either mechanism works. Placing the PHP inside a page template lets you take advantage of WordPress Template_Tags, which may save some time in the long run.

    See <a href="
    http://wordpress.org/support/topic/43916#post-245661">this post for some sample code.

  3. RaulTBC
    Member
    Posted 8 years ago #

    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?

  4. Ment0r
    Member
    Posted 8 years ago #

    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/

    regards, m3nt0r

  5. skippy
    Member
    Posted 8 years ago #

    RaulTBC: yes, you can connect to a different MySQL database manually using the mysql_connect() function from PHP.

  6. twhite56
    Member
    Posted 8 years ago #

    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?
    Thanks.

  7. trevorturk
    Member
    Posted 8 years ago #

    Add the template files to the theme directory, and check out this page for details.

    http://codex.wordpress.org/Stepping_Into_Templates#Template_Files_Within_Template_Files

  8. twhite56
    Member
    Posted 8 years ago #

    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.
    -Trevor

  9. RaulTBC
    Member
    Posted 8 years ago #

    skippy:

    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.

  10. trevorturk
    Member
    Posted 8 years ago #

    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...?

  11. skippy
    Member
    Posted 8 years ago #

    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.

  12. twhite56
    Member
    Posted 8 years ago #

    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.
    Thanks Again!
    -Trevor

  13. RaulTBC
    Member
    Posted 8 years ago #

    skippy:

    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.

  14. twhite56
    Member
    Posted 8 years ago #

    Anyone have an answer? Thanks.
    -Trevor

  15. candy2126
    Member
    Posted 7 years ago #

    I am having a site that supposrts osCommerce & the whole site is built in PHP, is it possible for me to create a static page like: http://www.example.com/products.com instead of the dynamic page?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.