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 2 of 2
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Shrink search bos to fit

    I have a custom search engine and I would like to have placed on web pages or as a pop out window. What would I do?

    PHP Code:
    <?php
    session_start
    ();
    ob_start();
    $title "Type here your search";
    if (
    $_REQUEST['q'] == $title$_REQUEST['q'] = "";
    include 
    "includes/config.php";
    include 
    "includes/functions.php";

    echo 
    "<!DOCTYPE html><html><head>";
    echo 
    "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
    echo 
    "<meta name=\"autor\" content=\"W4DJD\" />";
    echo 
    "<link type=\"text/css\" href=\"css/custom.css\" rel=\"stylesheet\" />";
    echo 
    "<link type=\"text/css\" href=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/redmond/jquery-ui.css\" rel=\"stylesheet\" />";
    echo 
    "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js\"></script>";
    echo 
    "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js\"></script>";
    echo 
    "<script type=\"text/javascript\" src=\"js/custom.js\"></script>";
    echo 
    "</head>";
    echo 
    "<body><div id=\"page\">";
    echo 
    "<h1 style=\"text-align: center\">Callsign Search Page</h1>";
    //echo "<input type=\"submit\" name=\"process\" value=\"\" class=\"fg-button ui-state-default ui-corner-all\" />";
    echo "<div>";
    echo 
    "<img id=\"info\" src=\"css/info.png\" width=\"60\" style=\"float: right; display: inline-block; margin-right: 120px; margin-top: 1px;\" />";
    echo 
    "<div id=\"process\" class=\"ui-widget ui-widget-content ui-corner-all\">";
        echo 
    "<form action=\"" $_SERVER['PHP_SELF'] . "\" method=\"post\">";
        echo 
    "<div style=\"display: inline-block; float: left; margin-left: 50px;\">";
        echo 
    "<select id=\"sf\" name=\"f\" class=\"ui-widget-content ui-corner-all field\">";
            echo 
    "<option value=\"callsign\"" . ((isset($_REQUEST['f']) && ($_REQUEST['f'] == "callsign")) ? " selected" "") . ">Callsign</option>";
            echo 
    "<option value=\"lastname\"" . ((isset($_REQUEST['f']) && ($_REQUEST['f'] == "lastname")) ? " selected" "") . ">Lastname</option>";
            echo 
    "<option value=\"firstname\"" . ((isset($_REQUEST['f']) && ($_REQUEST['f'] == "firstname")) ? " selected" "") . ">Firstname</option>";
            echo 
    "<option value=\"city\"" . ((isset($_REQUEST['f']) && ($_REQUEST['f'] == "city")) ? " selected" "") . ">City</option>";
            echo 
    "<option value=\"state\"" . ((isset($_REQUEST['f']) && ($_REQUEST['f'] == "state")) ? " selected" "") . ">State</option>";
            echo 
    "<option value=\"zipcode\"" . ((isset($_REQUEST['f']) && ($_REQUEST['f'] == "zipcode")) ? " selected" "") . ">ZipCode</option>";
        echo 
    "</select>";
        echo 
    "<input type=\"text\" name=\"q\" class=\"link ui-widget-content ui-corner-all defaultText\" title=\"" $title "\"" . (isset($_REQUEST['q']) ? " value=\"" $_REQUEST['q'] . "\"" "") . " />";
        echo 
    "</div>";
        echo 
    "<input type=\"image\" src=\"css/mg3.png\" name=\"process\" value=\"Search\" />";
        echo 
    "</form>";
    echo 
    "</div>";
    echo 
    "</div>";

    if (isset(
    $_REQUEST['q'])) {
        echo 
    "<div id=\"dialog\" title=\"Search Results\">";
        
    $select_fields "callsign,firstname,lastname,city,state,zipcode,class,country";
        
    $q trim($_REQUEST['q']);
        if (empty(
    $q)) {
            
    $query "SELECT " $select_fields " FROM import";
        }
        else {
            if (
    is_numeric($q) || ($_REQUEST['f'] == "callsign")) $query "SELECT " $select_fields " FROM import WHERE(`" $_REQUEST['f'] . "`='" mysql_real_escape_string($q) . "')";
            else 
    $query "SELECT " $select_fields " FROM import WHERE(`" $_REQUEST['f'] . "` LIKE '%" mysql_real_escape_string($q) . "%')";
        }
        
    $query .= " LIMIT 50";
        if ((
    $_REQUEST['f'] != "state") && !empty($q) && (strlen($q) < $cfg['min_q_characters'])) {
            echo 
    "<h1>Min. lenght search characters is " $cfg['min_q_characters'] . "</h1>";
        }
        else {
            
    $doit mysql_query ($query) or log_die("Query: " $query "\nError: " mysql_error() . "\nScript: " __FILE__ "\nLinia: " __LINE__);
            
    /* TEMPLATE
            echo "<div class=\"ui-widget ui-widget-content ui-corner-all label\">";
                echo "<h1 style=\"color: green\">callsign</h1>";
                echo "lastname firstname<br />";
                echo "city state<br />";
                echo "zipcode";
            echo "</div>";
            echo "<div style=\"clear: both\"></div>";
            */
            
            
    if (mysql_num_rows($doit) > 0) while ($tmp mysql_fetch_assoc($doit)) {
                echo 
    "<div class=\"ui-widget ui-widget-content ui-corner-all label\">";
                    
    $flag "flags/" $tmp['country'] . ".png";
                    if (
    file_exists($flag)) echo "<img src=\"" $flag "\" style=\"float: right; \">";
                    echo 
    "<h1 style=\"color: green; fint-family: Arial; fon-tize: 60px; font-weight: bold;\">" $tmp['callsign'] . "</h1>";
                    if (isset(
    $cfg['class_license'][$tmp['class']])) echo "Class license: " $cfg['class_license'][$tmp['class']] . "<br />";
                    echo 
    $tmp['lastname'] . " " $tmp['firstname'] . "<br />";
                    echo 
    $tmp['city'] . " " $tmp['state'] . "<br />";
                    echo 
    $tmp['zipcode'];
                echo 
    "</div>";
                echo 
    "<div style=\"clear: both\"></div>";
            }
            else {
                echo 
    "<center><img src=\"css/filenotfound.png\" /><br /><h1 style=\"display: inline-block; font-size: 28px; font-weight: bold;\">Record not found</h1></center>";
            }
        }
        echo 
    "</div>";
    }
    echo 
    "<div style=\"margin-top: 10px; text-align: center;\">";
    echo 
    "&copy; W4DJD 2011";
    echo 
    "\n";
          echo 
    "Database last updated on 9/01/2011";
    echo 
    "</div>";
    echo 
    "</div></body></html>";
    ob_end_flush();

    ?>

    FYI the Author is not available to consult for changes.

    This now opens on a full page and the search results come back in a pop out window. Can this be added to a webpage and still function as it should?

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,385
    Thanks
    8
    Thanked 1,077 Times in 1,068 Posts
    Are you working with a Joomla CMS based website?


    .


  •  

    Posting Permissions

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