SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Search Results 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 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>&nbsp;</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;
    //}

    ?>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Didn't you already ask this question?
    http://www.sitepoint.com/forums/showthread.php?t=627212

  3. #3
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No. the last post was based on a calculator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •