Searching MySQL with PHP -
I am doing a project where I want to enter an artist / band name in a text box Where it will be open my MySQL database for event information and display the results / content on the second page. The code below is within my index.php where it should get information from the search.ffp (also below). I have seen it completely and I am not sure why this is not working and I can not understand what to do. Help would be great! (I really need to pass this class!) :)
(index.php)
& lt; Form Name = "Search" action = "Search Php" method = "Received" & gt; & Lt; Div align = "center" & gt; & Lt; Input type = "article" name = "q" /> & Lt; P & gt; & Lt; Input type = "submit" name = "submit" value = "search" /> & Lt; / P & gt; & Lt; / Form & gt; (search.php)
& lt ;? Get the search variable from Php // URL $ var = @ & amp; _GET ['q']; $ Trimmings = trim ($ var); // Exclude spaces from spaces / lines // spaces to return $ range = 10; // Check for blank string and display the message. If ($ trimmed == "") {resonant " please enter a name. & Lt; / p & gt;"; Go out; } // Check for a search parameter if (! Isset ($ var)) {resonant "& lt; p> We do not find the search parameter! "; Go out; } // database connect to mysql_connect ("localhost", "root", "password"); // Specify mysql_select_db database ("Itor") or die ("Unable to select database"); // Create a SQL query $ query = "Select from events * where artist_name like \"% trimmed% \ "sorted by date"; $ Numresults = mysql_query ($ query); $ Numrows = mysql_num_rows (numresults); // If there are no results, offer a Google search as an option ($ numrows == 0) {resonance "
result "; Echo "& lt; p & gt; sorry, your search: & amp; quot;" $ Trimmed "& Amp; quot; Returned zero results & lt; / p & gt;"; // google echo "& lt; p & gt; & lt; a href =" http://www.google.com/search?q= "$ trimmed." \ "Target = \" _ blank \ "title = \" look-up \ "$ trimmed." To do a Google search, click on \ "& gt; here & lt; / a & gt; & lt; / p & gt;"; } // Next Setting that if the script is given, if 0 is not used (empty ($ s)) {$ s = 0; } // Get the result $ query. = "Border $ s, $ limit"; $ Result = mysql_query ($ query) or die ("query can not be executed"); // What was searched for "display" & lt; P & gt; You searched: & amp; Quot; ". $ Var" & Amp; Quot; & Lt; / P & gt; "/ / results result set echo start to show" results "; $ count = 1 + $ s; // When results returned, ($ line = mysql_fetch_array ($ result)) {$ title = $ Row ["artist_name"]; echo "$ count) & amp ;. Nbsp; $ Heading "$ counts ++;} $ CurrPage = (($ s / $ limit) + 1;" = 1) {// Bypass PREV link if S $ is $ first = ($ s- $ limit); print "& amp; nbsp; & lt; a href = \" $ PHP_SELF? S = $ prevs and q = $ var Calculate the number of pages that require \ "& gt; and amp; lt; & amp; lt; last 10
You're missing the $ symbol I think that
$ var = @ & amp; _GET ['q']; probably should be
$ var = @ $ _GET ['q']; Unless you really want a reference, in that case it should be: (If you If you want a reference, then this need is not required, but you should check $ var before trying to access it)
$ var = & amp; $ _GET ['Q ']; I It'll do little to write more.
if (! Isset ($ _ GET [ 'q'])) {echo "& Lt; P & gt; We do not find the search parameters! & Lt; / P & gt; "; go out;} $ Trimmed = trim ($ _GET ['q']); if ($ trimmed ==" ") {resonant" & lt; P & gt; Please enter a name. & Lt; / P & gt; "; go out;}
Comments
Post a Comment