WordPress.org

Forums

Need help using my own PHP/HTML in WordPress (4 posts)

  1. Vinnyfan
    Member
    Posted 2 years ago #

    I had a fully-functional web site hosted on Blue Host, but decided that I'd rather stick to the programming, not design, so I wiped out my stuff and installed WordPress. My intent is to use WordPress for the themes, comments, and blogging part of this site, if I choose to blog down the road, but I want MY stuff to be selectable from a PAGE.

    I figured the home page would be an introduction to the site, which is a database lookup for several different things pertaining to music by Vince Gill. The next PAGE, currently called SAMPLE is where the PHP is which drives the lookup.

    I copied the source from one of my pages of the site that used to work and pasted it into the text editor in WordPress. It will not process all the code. It displays the code as text. What am I doing wrong?

    Here's the code:

    [please review how to post code: http://codex.wordpress.org/Forum_Welcome#Posting_Code
    part of the code below got broken by the forum's parser]

    <?php require_once("connection.php"); ?>
    <?php include("header.php"); ?>
    
    <?php
    $result = mysql_query("SELECT * FROM VGVocalists ORDER BY LastName, FirstName",$connection);
       if ($result == false) {
        die("Database query failed: " . mysql_error());
       }
    	echo "<div>";
    	echo "<form action='VGBGVSResults.php' method='post'>";
    	echo  "<p><h3>Display info on all vocalists or choose
    	              one from the drop-down list</h3>";
    	echo  "<select name=selinput>";
    	echo   "<option value=All>All Vocalists</option>";
    	    while ($row = mysql_fetch_array($result)) {
    	      echo "<option value='{$row[Name]}'>{$row[Name]}
    	      </option>";
    	    }
    	echo "</select>";
            echo "</p>";
    	echo "<input type='submit'>";
    	echo "</form>";
    	echo "</div>";
    ?>     
    
    <div>
    
    <a href="index.php">Return to main page</a>
    </div>
    
       <div>
    	<?php include("copyright.php"); ?>
       </div>
    
      </body>
    </html>

    The website is http://www.vinnyfan.com

  2. martcol
    Member
    Posted 2 years ago #

    I don't know much about the code side of things myself but it looks to me that you are not thinking about WordPress own schema.

    your WordPress install has its own db and a raft of functions and stuff.

    I can only think to suggest that you take a good look at WordPress template hierarchy, the loop and some of the template tags.

  3. alchymyth
    Forum Moderator
    Posted 2 years ago #

    copied the source from one of my pages of the site that used to work and pasted it into the text editor in WordPress

    php code does not work in the content of posts or pages, unless you use a plugin to enable that; http://wordpress.org/extend/plugins/search.php?q=php+in+pages

    a different approach would be to create page templates for the purpose of making pages with custom php code; http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

  4. Vinnyfan
    Member
    Posted 2 years ago #

    Thank you both for the quick responses. I've started reading about the templates and it looks like that will work (when I eventually get it all figured out). I appreciate your assistance!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.