if($_GET['id']=="szukaj"){ include("search.php"); }
a na stronie glownej umiescic tylko hiperlacze do search.php
Ale chce się nauczyc czego innego, szukam innych rozwiazan, ale jeszcze poczatkowych (nie wszystko odrazu

Z góry dzięki

if($_GET['id']=="szukaj"){ include("search.php"); }
// These are the available "error strings" you can change them to affect the output // of the search engine. document.writeln("<i>"); ERR_NoOptions = "Błąd"; ERR_NoSearchTerms = "Wpisz nazwe"; ERR_NoResults = "Nie znaleziono"; document.writeln("</i>"); // Performs an actual search and then returns the index number(s) in the db array // where it found this element. // keywords = the string they searched for (each space-separated word // is searched for separately) // options can be // 1 = search keywords, not description, not heading // 2 = search keywords, search description, not heading // 3 = search all function performSearch(keywords, options) { // Check to make sure they entered some search terms if (!keywords || keywords.length == 0) { return ERR_NoSearchTerms; } // Determine where to check for the keywords entered if (options == 0) { return ERR_NoOptions; } else if (options == 1) { searchKeywords = true; searchDescription = false; searchHeading = false; } else if (options == 2) { searchKeywords = true; searchDescription = true; searchHeading = false; } else if (options == 3) { searchKeywords = true; searchDescription = true; searchHeading = true; } // Setting up the keywords array for searching // Remove common punctuation keywords = keywords.replace("\.,'", ""); // get them all into an array so we can loop thru them // we assume a space was used to separate the terms // This is where we will be putting the results. // Loop through the db for potential results // For every entry in the "database" for (sDB = 0; sDB < searchDB.length; sDB++) { // For every search term we are working with for (t = 0; t < searchFor.length; t++) { // Check in the heading for the term if required if (searchHeading) { if (searchDB[sDB].heading.toLowerCase().indexOf(searchFor[t].toLowerCase()) != -1) { results[results.length] = String(sDB); } } } // Check in the keywords for the term if required if (searchKeywords) { if (searchDB[sDB].terms.toLowerCase().indexOf(searchFor[t].toLowerCase()) != -1) { results[results.length] = String(sDB); } } } // Check in the description for the term if required if (searchDescription) { if (searchDB[sDB].description.toLowerCase().indexOf(searchFor[t].toLowerCase()) != -1) { results[results.length] = String(sDB); } } } } } if (results.length > 0) { return results; } else { return ERR_NoResults; } } // Constructor for each search engine item. // Used to create a record in the searchable "database" function searchOption(heading, terms, description, url) { this.heading = heading; this.terms = terms; this.description = description; this.url = url; return this; } // Returns true or false based on whether the specified string is found // in the array. // This is based on the PHP function of the same name. // stringToSearch = the string to look for // arrayToSearch = the array to look for the string in. for (s = 0; s < arrayToSearch.length; s++) { if (arrayToSearch[s].indexOf(stringToSearch) != -1) { return true; exit; } } return false; } // This function grabs a specified value from a GET-style URL // you call it with the name of the variable and it returns // the value, or false if not found. function getURLvalue(getName) { // get the string following the question mark queryString = location.href.substring(location.href.indexOf("?")+1); // split parameters into pairs, assuming pairs are separated by ampersands // for each pair, we get the name and the value for (i = 0; i < pairs.length; i++) { continue; } // Replaces "Google-style" + signs with the spaces // they represent if (argname == getName) { return unescape(argvalue.replace(/\+/g, " ")); } } return false; } // Function to execute when the focus is passed to the search filed. // It just selects everything in the field, which will mean that if // the user clicks the search field then types, the placeholder text // will be removed automagically :) // call using onFocus="java script:searchFocus(this); function searchFocus(searchField) { searchField.focus(); searchField.select(); }
<html> <head> <title>Search Example</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script language="JavaScript1.2" src="searchEngine.js"></script> <script language="JavaScript1.2" src="searchDB.js"></script> <style type="text/css"> .result { margin: 10px 0; } .result-title { font-weight: bold; } .result-desc { font-size: 90%; } #conterbody { background: white; } #conter { background: #e4ecf4; color: black; border: 1px solid black; margin-left: 25%; width: 50%; margin-top: 100px; padding: 10px; } #conter a { color: blue; } </style> </head> <body bgcolor="#FFFFFF" text="#000000"> <script type="text/javascript"> <!-- function searchForm() { ///////////////////////////////////////////////////////////// // This is the search form, plus anything else to display when // the user hasn't searched yet. *MUST* use "get" as the method on the form and "searchTxt" as the search field name document.writeln("<form name=\"search\" action=\"search.php\" method=\"get\">"); document.writeln(" <input type=\"text\" name=\"searchTxt\"value=\"wpisz kraj lub stolicę\" onclick=\"if(this.value=='wpisz kraj lub stolicę') this.value=''\" onblur=\"if(this.value=='') this.value='wpisz kraj lub stolicę'\" />"); document.writeln("<input type=\"submit\" value=\"szukaj\" name=\"search\" />"); document.writeln("Przy kożystaniu z IE nie naciskaj ENTER tylko klikaj SZUKAJ"); document.writeln("</form>"); ///////////////////////////////////////////////////////////// } if (getURLvalue('search')) { document.writeln("<div id=\"conterbody\"><div id=\"conter\">"); } if (getURLvalue('search')) { // Do the search results = performSearch(getURLvalue("searchTxt"), 3); if (results) { // This means that there are search results to be displayed. // Loop through them and make it pretty! :) document.writeln("<i>Znaleziono</i> ["+ results.length +"] <i>podpowiedzi</i>:<br>\n"); document.writeln("<ol>"); for (r = 0; r < results.length; r++) { result = searchDB[results[r]]; ///////////////////////////////////////////////////////////// // This is where you modify the formatting of the results document.writeln("<li class=\"result\"><div class=\"result-title\"><a href=\"" + result.url + "\">" + result.heading + "</a></div>"); document.writeln("<div class=\"result-desc\">" + result.description + "</div></li>"); ///////////////////////////////////////////////////////////// } document.writeln("</ol>"); } // If it's not an array, then we got an error message, so display that // rather than results else { document.writeln("<i>" + results + "</i>"); document.writeln("<br />"); } document.writeln(" <form name=\"search\" action=\"search.php\" method=\"get\"> <input type=\"text\" name=\"searchTxt\" /><input type=\"submit\" value=\"szukaj\" name=\"search\" /></form><br><br><a href=\"index.php\">wróc</a></div></div>\n"); } else { searchForm(); } } else { searchForm(); } // --> </script> </body> </html>