hitman123
21 Jul 2009, 06:28 AM
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 the page. I've been working on this for literally 3 days but getting no where, please help.
I have a text box and a search button next to it. so When I put in a search and click search, the results should appear in the ref text box. I hope you understand what I mean. Please Help. Here is the code:
<form action="test_search.php" method="get">
<input type="text" name="query" id="query" size="40" value="" action="Search.php" columns="2" autocomplete="off" delay="1500">
<input type="submit" value="Search">
<input type="hidden" name="search" value="1">
</form>
<center></center>
</div>
<p> </p>
<?
$myServer = '*****';
$myUser = '****';
$myPass = '*****';
$myDB = '*******';
$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");
//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 ******** WHERE Spec_Ref LIKE'$SpecRef%' ");
// $query = ("SELECT * FROM *******");
print(' is what you searched for:');
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Record" . ($numRows == 1 ? "" : "s") . " Found </h1>";
//display the results
echo '<textarea>';
while($row = mssql_fetch_array($result))
{
echo $row["Spec_Ref"] . "\n"; }
echo '</textarea>';
//close the connection
mssql_close($dbhandle);
//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["Spec_Ref"] . "</li>";
}
//close the connection
mssql_close($dbhandle);
//textareaContent = "";
//while ($row = @mysql_fetch_array($query))
//{
//$var1=$row["Player"];
//$var2=$row["Avg"];
//$var3=$row["HR"];
//$var4=$row["RBI"];
$textareaContent .= "Spec Ref: $var1 Avg: $var2 HR: $var3 RBI $var4 <br/>";
//}
//if (!isset($var1) || $var1=="") {
//echo $XX;
//}
?>
I have a text box and a search button next to it. so When I put in a search and click search, the results should appear in the ref text box. I hope you understand what I mean. Please Help. Here is the code:
<form action="test_search.php" method="get">
<input type="text" name="query" id="query" size="40" value="" action="Search.php" columns="2" autocomplete="off" delay="1500">
<input type="submit" value="Search">
<input type="hidden" name="search" value="1">
</form>
<center></center>
</div>
<p> </p>
<?
$myServer = '*****';
$myUser = '****';
$myPass = '*****';
$myDB = '*******';
$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");
//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 ******** WHERE Spec_Ref LIKE'$SpecRef%' ");
// $query = ("SELECT * FROM *******");
print(' is what you searched for:');
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Record" . ($numRows == 1 ? "" : "s") . " Found </h1>";
//display the results
echo '<textarea>';
while($row = mssql_fetch_array($result))
{
echo $row["Spec_Ref"] . "\n"; }
echo '</textarea>';
//close the connection
mssql_close($dbhandle);
//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["Spec_Ref"] . "</li>";
}
//close the connection
mssql_close($dbhandle);
//textareaContent = "";
//while ($row = @mysql_fetch_array($query))
//{
//$var1=$row["Player"];
//$var2=$row["Avg"];
//$var3=$row["HR"];
//$var4=$row["RBI"];
$textareaContent .= "Spec Ref: $var1 Avg: $var2 HR: $var3 RBI $var4 <br/>";
//}
//if (!isset($var1) || $var1=="") {
//echo $XX;
//}
?>