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 */ ?>
Well if you want to do it on the fly without a page reload then your going to need to do it via Ajax or something, if page reload is allowable then just check if the form has been submtited, and if so echo the results inside the text area, else the search hasnt been submitted yet.
benokshosting.co.uk - search box is in the top right of the menu bar. Type "benoks" in the bar, it drops down with menu items. Do you mean like that?
Well every result is stored in a table, we use jQuery to pull the data out from the return value. You can download the ZIP with everything in, james-brooks.net/downloads/jQuery-Search.zip
I said, jQuery. There isn't anything too confusing. Here is the export of some of our MySQL code: CREATE TABLE IF NOT EXISTS `search` ( `id` int(11) NOT NULL auto_increment, `url` text NOT NULL, `name` text NOT NULL, `keywords` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; INSERT INTO `search` (`id`, `url`, `name`, `keywords`) VALUES (1, 'http://www.benokshosting.co.uk', 'Benoks Hosting', 'Benoks, Hosting, Welcome, Home, Homepage'), (2, 'http://www.benokshosting.co.uk/index.php?page=plans', 'Plans', 'plans, packages, copper, bronze, silver, gold, custom'), (3, 'http://www.benokshosting.co.uk/index.php?page=support', 'Support', 'support, contact, help, advice, server'), (4, 'http://www.benokshosting.co.uk/index.php?page=about', 'About', 'about, company, history, bennett, brooks, benoks'), (5, 'http://www.benokshosting.co.uk/index.php?page=contact', 'Contact', 'contact, support, help, information, email'), (6, 'http://www.benokshosting.co.uk/forum/index.php', 'Forum', 'forum, community, support, help, online, programming, scripting, server, chat'), (7, 'http://www.benokshosting.co.uk/index.php?page=login', 'Client Area', 'client, area, login, register, order, whmcs, packages, plans, hosting, buy now, order'), (8, 'http://www.benokshosting.co.uk/services', 'PSD2XHTML', 'PSD, XHTML, HTML, CSS, PSD2XHTML, PSD2HTML'); Code (markup): The only file you need to edit is includes/search.php
Ive just been back on to the site and typed benoks in the search. But i've noticed when you click on the results, it loads onto a new page. I want them results in the text box. Im pretty confused how to do this
Then it's not what you wanted is it. Do you have an example anywhere? Upload files exactly how you download them.
Please see the following link: http://learoyd-sql/test_search.php?query=&search=1 This is what I have designed. All I want it to do is that the results that are already displayed, I want them removed and want them results in that text box. I can post the code if that helps