WordPress.org

Ready to get started?Download WordPress

Forums

To search WP database... send form where? (2 posts)

  1. quite_bemused
    Member
    Posted 1 year ago #

    Hi all,

    Absolute newbie trying to code. I'm trying to search my database based on a number of criteria where the user has selected from drop-down menus.

    To try to get it working I've cut the code back to searching for one criterion (difficulty) but I've realised I don't know where to send it! I'd like to put "search.php" or similar after "action = " but the file doesn't exist and I don't know how to create it.

    Any help appreciated!

    Draft code below:

    <form method="post" action="">
    <select name="Difficulty">
    <option value="" selected="selected">-any-</option>
    <option value="For_children">For_children</option>
    <option value="Easy">Easy</option>
    <option value="Medium">Medium</option>
    <option value="Hard">Hard</option>
    <option value="Very Hard">Very Hard</option>
    </select>
    <input type="submit" value="search">
    </form>

    [php]

    global $wpdb;

    $difficulty=MySQL_real_escape_string($_POST["Difficulty"]);
    $result = MySQL_query("SELECT * from Attributes WHERE Difficulty == '%$difficulty'

    echo $result

    [/php]

  2. quite_bemused
    Member
    Posted 1 year ago #

    I've also tried copying the form part of the above into a text file, zipping it and then importing it as a .php template, but get the error message:

    "The theme is missing the style.css stylesheet."

    All help appreciated!

    Thanks

    - Daniel

Topic Closed

This topic has been closed to new replies.

About this Topic