#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    40
    Rep Power
    2

    Create button to instantly refine PHP pages


    Hello friends and programmers ..

    I am trying to have a button that instantly refines my searches

    Something like

    Onclick("SELECT * FROM TBL WHERE Description LIKE $value")

    Is this something a newbie could pull of or does it require more than just working knowledge of PHP, MYSQL, and Javascript

    I have looked through Google, but have not found a good resource to base my script on.

    Thanks
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,183
    Rep Power
    184
    It looks like your just looking for a search form. You really do not need JavaScript for this; unless your wanting to use AJAX to retrieve the search results. You could do this with a basic form (example below).
    Code:
    <form action="search.php" method="get">
    <input type="text" name="context"/>
    <input type="submit" value="search"/>
    </form>
    search.php
    Code:
    <?php
    $value = $_GET["context"];
    // connect here
    $query = mysql_query("SELECT * FROM TBL WHERE Description LIKE $value");
    // while... 
     // display results here
    ?>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    40
    Rep Power
    2

    Re:


    Thanks for the reply, but I've already got that working along with pagination.

    What I want is a checkbox, that once clicked, will produce the results instantly - input the term such as "Canada" and then display results that were posted in Canada

    I imagine this would require some basic javascript and I'm unsure of where to start.

    Thanks.
  6. #4
  7. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,183
    Rep Power
    184
    You need to get AJAX involved with this. What you would do is set-up a AJAX function to send a query to your php page and then return the responseText back to a html element (ie. a div tag). Then add this function to your checkbox element, in the form of a onclick event. That's probably how I would go about something like this.
    Last edited by web_loone08; May 6th, 2013 at 05:46 PM.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    9
    Rep Power
    0
    Start here http://www.w3schools.com/ajax/ajax_examples.asp. On w3schools you will found a lot of resources on the topic.

IMN logo majestic logo threadwatch logo seochat tools logo