hitmaDn123 Posted July 15, 2009 Share Posted July 15, 2009 Hi I hope you can help, its pretty urgent. I have created a search box which potentially works. But I wish to insert the results in to the text box rather than having them on a new page. I have a text box called ref and a search button next to it. so When I put in a search in the ref and click search, the results should appear in the ref text box. I hope you understand what I mean. I know you ahve to define a variable and assign it to the text box, but the question is how> please help. Below is the code for the search box: <? $myServer = 'learoyd-sql'; $myUser = 'sa'; $myPass = '25141260'; $myDB = 'CompanyL'; $SpecRef = $_GET['query']; print ("$SpecRef"); //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); <form action="search.php" method="get"> <input type="text" name="query" id="query" size="40" value="" action="include/js_suggest/suggest.php" columns="2" autocomplete="off" delay="1500" /> <input type="submit" value="Search"> <input type="hidden" name="search" value="1"> </form> <center><a href="search2.php?adv=1">Advanced search</a></center> </div> //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); //error message (not found message)begins $XX = "No Matches Found"; //query details table begins $query = ("SELECT * FROM dbo.DesignControl WHERE Spec_Ref LIKE'$SpecRef%' "); // $query = ("SELECT * FROM dbo.DesignProcess"); print('$query'); //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>"; //display the results while($row = mssql_fetch_array($result)) { echo "<li>" . $row["Spec_Ref"] . "</li>"; } //close the connection mssql_close($dbhandle); /*while ($row = @mysql_fetch_array($query)) { $variable1=$row["Player"]; $variable2=$row["Avg"]; $variable3=$row["HR"]; $variable4=$row["RBI"]; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("</tr>"); } //below this is the function for no record!! if (!$variable1) { print ("$XX"); } //end */ ?> Quote Link to comment https://forums.phpfreaks.com/topic/166094-search-box/ Share on other sites More sharing options...
anthylon Posted July 25, 2009 Share Posted July 25, 2009 Well, it looks like you want to retrieve value from database without reloading your web page. If that is the case you could use Ajax to make it works. Reloading page just to insert value wouldn't have sense but it is easy to make. Quote Link to comment https://forums.phpfreaks.com/topic/166094-search-box/#findComment-882576 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.