Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Custom Search Box

    Im trying to figure out how to create a local search box for my site.

    I want to be able to search pictures by file name. I want the search to return up to 50 results, but display only the top 3 (the idea is if the top 3 aren't a match they can load 3 pics at a time....)

  • #2
    New Coder
    Join Date
    Nov 2013
    Posts
    20
    Thanks
    0
    Thanked 2 Times in 2 Posts
    I could do this for you but I would have to charge because it would be time consuming. Message me with a quote and we can work something out.

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,092
    Thanks
    23
    Thanked 594 Times in 593 Posts
    IMHO using php makes things harder then doing it in javascript. No errors, no reset without some programming.

    This is not perfect but does a good job and I think it's a great start:

    The PHP file:
    PHP Code:
    <?php
    $first 
    '';
    $sec '';
    $res '';
    $message1 '';
    if(isset(
    $_GET['reset'])){
        
    $first '';
        
    $sec '';
        
    $res '';
        
    $message1 '';
    }else{
        if(isset(
    $_GET['text1']) && isset($_GET['text2'])) {
            
    $tag 1;
            
    $first $_GET['text1'];
            
    $sec $_GET['text2'];
            if(!
    is_numeric($first)){
                
    $message1 "This must be a number";
                
    $first $message1;
                
    $tag 2;
            }
            if(!
    is_numeric($sec)){
                
    $message1 "This must be a number";
                
    $sec $message1;
                
    $tag 2;
            }
            if(
    $tag == 1){
                
    $res $_GET["text1"] + $_GET["text2"];
            }
        }
    }
    ?>
    <html>
    <head>
    <title>Add two numbers on same form</title>
    <style type="text/css">
    body{
        width: 960px;
    }
    #here{
        width: 300px;
        height: 200px;
        margin: 0 auto;
    }
    h1{
        color: blue;
    }
    input{
        float:right;
    }
    label{
        float:left;
    }
    button{
        margin-top: 5px;
    }
    <?php if($tag == 2){
    echo 
    "input{color: red;}";
    }
    ?>
    </style>
    </head>

    <body>
    <div id="here">
        <form method="get" action="#" accept>
            <h1>Sum Two Numbers</h1>
    <p>
            <label for="text1">Enter First Number</label>
            <input type="text" name="text1" value="<?= $first?>">
    </p>
    <p>
            <label for="text2">Enter Second Number</label>
            <input type="text" name="text2" value="<?= $sec?>">
    </p>
    <p>
            <label for="result">Result</label>
            <input type="text" name="result" value="<?= $res?>" disabled>
    </p><br />

    <div style="margin-top:55px;">
        <input type="submit" value="Calculate" style="float:left;">
        <input type="submit" name="reset" value="Reset">
    </div>

        </form>
    </div>
    </body>
    </html>
    Last edited by sunfighter; 11-04-2013 at 09:42 PM.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •