I have a perfectly functioning search tool with the standard type, click submit and results are displayed. I am making use of the FULLTEXT procedure at present.
I was wondering if it is possible to have a function whereby as you type in a textbox/ listbox the words start to appear. This can be demonstrated easily in MS Access with the combo box I believe.

Here is my current setup:

 if ($search == "general") {$sql= "SELECT * FROM qualityquestsite WHERE MATCH (content) AGAINST ('" . stripslashes (str_replace (""", "\"", ($_POST['search']))) . "' IN BOOLEAN MODE)"; 

$result = mysql_query($sql, $connection) or die(mysql_error()); 
if (mysql_num_rows($result) > 0) { 
while ($row = mysql_fetch_assoc($result)) { 

// begin output here: 
echo '
<TABLE BORDER=1 CELLPADDING=2>
<TR> <TH COLSPAN=2 BGCOLOR="#99CCFF"></TH> </TR>

<TR> <TD WIDTH=500><a href="' . $row['search_url'] . '">' . $row['search_title'] . '</a></TD> <TD WIDTH=250>' . $row['search_section'] .'</TD> </TR>

</TR>

</TABLE>';
    11 days later

    thanks Kudose. this looks like what I am after. only trouble is i'm not sure how to populate the array by accessing a MySQL table. Have you used the example in this context?

      this is the code as it stands...

      <?php
      
      /*
      note:
      this is just a static test version using a hard-coded countries array.
      normally you would be populating the array out of a database
      
      the returned xml has the following structure
      <results>
      	<rs>foo</rs>
      	<rs>bar</rs>
      </results>
      */
      
      $aCountries = array(
      	"Afghanistan",
      	"Albania",
      	"Algeria",
      	"Andorra",
      	"Angola",
      	"Antigua and Barbuda",
      	"Argentina",
      	"Armenia",
      	"Australia",
      	"Austria",
      	"Azerbaijan",
      	"Bahamas",
      	"Bahrain",
      	"Bangladesh",
      	"Barbados",
      	"Belarus",
      	"Belgium",
      	"Belize",
      	"Benin",
      	"Bhutan",
      	"Bolivia",
      	"Bosnia and Herzegovina",
      	"Botswana",
      	"Brazil",
      	"Brunei",
      	"Bulgaria",
      	"Burkina Faso",
      	"Burundi",
      	"Cambodia",
      	"Cameroon",
      	"Canada",
      	"Cape Verde",
      	"Central African Republic",
      	"Chad",
      	"Chile",
      	"China",
      	"Colombia",
      	"Comoros",
      	"Congo (Brazzaville)",
      	"Congo, Democratic Republic of the",
      	"Costa Rica",
      	"Côte d'Ivoire",
      	"Croatia",
      	"Cuba",
      	"Cyprus",
      	"Czech Republic",
      	"Denmark",
      	"Djibouti",
      	"Dominica",
      	"Dominican Republic",
      	"East Timor",
      	"Ecuador",
      	"Egypt",
      	"El Salvador",
      	"Equatorial Guinea",
      	"Eritrea",
      	"Estonia",
      	"Ethiopia",
      	"Fiji",
      	"Finland",
      	"France",
      	"Gabon",
      	"Gambia, The",
      	"Georgia",
      	"Germany",
      	"Ghana",
      	"Greece",
      	"Grenada",
      	"Guatemala",
      	"Guinea",
      	"Guinea-Bissau",
      	"Guyana",
      	"Haiti",
      	"Honduras",
      	"Hungary",
      	"Iceland",
      	"India",
      	"Indonesia",
      	"Iran",
      	"Iraq",
      	"Ireland",
      	"Israel",
      	"Italy",
      	"Jamaica",
      	"Japan",
      	"Jordan",
      	"Kazakhstan",
      	"Kenya",
      	"Kiribati",
      	"Korea, North",
      	"Korea, South",
      	"Kuwait",
      	"Kyrgyzstan",
      	"Laos",
      	"Latvia",
      	"Lebanon",
      	"Lesotho",
      	"Liberia",
      	"Libya",
      	"Liechtenstein",
      	"Lithuania",
      	"Luxembourg",
      	"Macedonia",
      	"Madagascar",
      	"Malawi",
      	"Malaysia",
      	"Maldives",
      	"Mali",
      	"Malta",
      	"Marshall Islands",
      	"Mauritania",
      	"Mauritius",
      	"Mexico",
      	"Micronesia",
      	"Moldova",
      	"Monaco",
      	"Mongolia",
      	"Morocco",
      	"Mozambique",
      	"Myanmar",
      	"Namibia",
      	"Nauru",
      	"Nepal",
      	"Netherlands",
      	"New Zealand",
      	"Nicaragua",
      	"Niger",
      	"Nigeria",
      	"Norway",
      	"Oman",
      	"Pakistan",
      	"Palau",
      	"Panama",
      	"Papua New Guinea",
      	"Paraguay",
      	"Peru",
      	"Philippines",
      	"Poland",
      	"Portugal",
      	"Qatar",
      	"Romania",
      	"Russia",
      	"Rwanda",
      	"Saint Kitts and Nevis",
      	"Saint Lucia",
      	"Saint Vincent and The Grenadines",
      	"Samoa",
      	"San Marino",
      	"Sao Tome and Principe",
      	"Saudi Arabia",
      	"Senegal",
      	"Serbia and Montenegro",
      	"Seychelles",
      	"Sierra Leone",
      	"Singapore",
      	"Slovakia",
      	"Slovenia",
      	"Solomon Islands",
      	"Somalia",
      	"South Africa",
      	"Spain",
      	"Sri Lanka",
      	"Sudan",
      	"Suriname",
      	"Swaziland",
      	"Sweden",
      	"Switzerland",
      	"Syria",
      	"Taiwan",
      	"Tajikistan",
      	"Tanzania",
      	"Thailand",
      	"Togo",
      	"Tonga",
      	"Trinidad and Tobago",
      	"Tunisia",
      	"Turkey",
      	"Turkmenistan",
      	"Tuvalu",
      	"Uganda",
      	"Ukraine",
      	"United Arab Emirates",
      	"United Kingdom",
      	"United States",
      	"Uruguay",
      	"Uzbekistan",
      	"Vanuatu",
      	"Vatican City",
      	"Venezuela",
      	"Vietnam",
      	"Western Sahara",
      	"Yemen",
      	"Zambia",
      	"Zimbabwe"
      );
      
      
      $input = strtolower( $_GET['input'] );
      $len = strlen($input);
      
      $aResults = array();
      
      if ($len)
      {
      	for ($i=0;$i<count($aCountries);$i++)
      	{
      		if (strtolower(substr($aCountries[$i],0,$len)) == $input)
      			$aResults[] = $aCountries[$i];
      	}
      }
      
      header("Content-Type: text/xml");
      
      echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
      <results>";
      	for ($i=0;$i<count($aResults);$i++)
      		echo"	<rs>".$aResults[$i]."</rs>";
      	echo "
      </results>
      	";
      
      ?>
      

        well, in your while loop as you have now, populate an array during that loop, instead of doing your normal display with tables, just create a string comma-delimited and create your array out of that

          how would I create a string delimited array? I'm trying to fetch jargon terms for a table called jargon?

            Update

            I have looked at the manual and I think the explode function is appropriate for this instance. I tried this

            $sql= "SELECT * FROM jargon";
            
            $result = mysql_query($sql, $connection) or die(mysql_error()); 
            if (mysql_num_rows($result) > 0) { 
            while ($row = mysql_fetch_assoc($result)) { 
            
            // begin output here: 
            	$aCountries = explode($',', $row['jargonterm']);
            
            }
            
            $input = strtolower( $_GET['input'] );
            $len = strlen($input);
            
            $aResults = array();
            
            if ($len)
            {
            	for ($i=0;$i<count($aCountries);$i++)
            	{
            		if (strtolower(substr($aCountries[$i],0,$len)) == $input)
            			$aResults[] = $aCountries[$i];
            	}
            }
            
            header("Content-Type: text/xml");
            
            echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
            <results>";
            	for ($i=0;$i<count($aResults);$i++)
            		echo"	<rs>".$aResults[$i]."</rs>";
            	echo "
            </results>
            	";
            
            

            but as I type in the textbox nothing happens. Their are no error messages either

              As usual i'm a little slow on the up take here. Im having trouble interpreting what you meant in terms of push the result onto the end of the array. Here is my lame effort which doesn't lookup when typing!

              $sql= "SELECT * FROM jargon";
              
              $result = mysql_query($sql, $connection) or die(mysql_error()); 
              if (mysql_num_rows($result) > 0) { 
              while ($aCountries = mysql_fetch_assoc($result)) { 
              
              // begin output here: 
              	echo $aCountries['jargonterm'];
              
              }
              
              $input = strtolower( $_GET['input'] );
              $len = strlen($input);
              
              $aResults = array();
              
              if ($len)
              {
              	for ($i=0;$i<count($aCountries);$i++)
              	{
              		if (strtolower(substr($aCountries[$i],0,$len)) == $input)
              			$aResults[] = $aCountries[$i];
              	}
              }
              
              header("Content-Type: text/xml");
              
              echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
              <results>";
              	for ($i=0;$i<count($aResults);$i++)
              		echo"	<rs>".$aResults[$i]."</rs>";
              	echo "
              </results>
              	";
              
              ?>
              

                just an example

                <?
                $query = "SELECT fieldname FROM tablename"; 
                $result = mysql_query($query) or die(mysql_error());
                
                while ($row = mysql_fetch_array($result))
                {      
                $results_array = array(); $results_array[] = $row['fieldname']; } ?>

                that'll give you a real array with your results from the table, by real array, i mean just like if you made one like ("first", "second", "third"), this is untested as well for syntax so you may have to tweak it a bit for semicolons, missing {}, etc...

                  appreciate the help and your patience stolzyboy. To be honest I think the problem may not be PHP related. I am still not getting any error messages nor results when I type in a jargont term. There is a Javascript aspect to this function - and if the list is hard coded like I show in the first thread there are no problems but im thinking maybe what im trying to do is just not possible.

                  <?php
                  
                  /*
                  note:
                  this is just a static test version using a hard-coded countries array.
                  normally you would be populating the array out of a database
                  
                  the returned xml has the following structure
                  <results>
                  	<rs>foo</rs>
                  	<rs>bar</rs>
                  </results>
                  */
                  include("connect.php");
                  $query = "SELECT * FROM jargon"; 
                  $result = mysql_query($query) or die(mysql_error()); 
                  
                  while ($row = mysql_fetch_array($result)) 
                  {       
                  $aCountries = array(); $aCountries[] = $row['jargon_term']; } $input = strtolower( $_GET['input'] ); $len = strlen($input); $aResults = array(); if ($len) { for ($i=0;$i<count($aCountries);$i++) { if (strtolower(substr($aCountries[$i],0,$len)) == $input) $aResults[] = $aCountries[$i]; } } header("Content-Type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?> <results>"; for ($i=0;$i<count($aResults);$i++) echo" <rs>".$aResults[$i]."</rs>"; echo " </results> "; ?>

                    is the array being populated??

                    what shows up if you do

                    print_r($aCountries);

                    and i'm pretty sure what you are doing can be done, or the search/ajax tool would be useless if you had to type in all the entries (in a dictionary-type app for example)

                    stolzyboy

                      if i try

                      print_r($aCountries);

                      nothing shows up

                        BTW, this is wrong:

                        while ($row = mysql_fetch_array($result))
                        {       
                        $aCountries = array(); $aCountries[] = $row['jargon_term']; }

                        $aCountries is now being reset on every row. Use:

                        $aCountries = array();
                        while ($row = mysql_fetch_array($result))
                        {       
                        $aCountries[] = $row['jargon_term']; }

                        But atleast it should have printed out the last item with print_r. Or even array() if it were empty. Did you print it out BEFORE the header? Something like this would suffice:

                        ...
                            $aCountries[] = $row['jargon_term'];
                        }
                        print_r($aCountries);
                        die();
                        

                          I have made the changes and put :

                          <?php
                          print_r($aCountries);
                          ?>
                          

                          at the very top of my code/HTML text so it is the first possible output- still no results and no error messages nor are there any terms listed when I begin to type in the box

                            sorry disregard what i just tried- I meant I tried this and the same results:

                            ?php
                            
                            /*
                            note:
                            this is just a static test version using a hard-coded countries array.
                            normally you would be populating the array out of a database
                            
                            the returned xml has the following structure
                            <results>
                            	<rs>foo</rs>
                            	<rs>bar</rs>
                            </results>
                            */
                            include("connect.php");
                            $query = "SELECT * FROM jargon"; 
                            $result = mysql_query($query) or die(mysql_error()); 
                            
                            $aCountries = array(); 
                            while ($row = mysql_fetch_array($result)) 
                            {        
                            $aCountries[] = $row['jargon_term']; } print_r($aCountries); die(); $input = strtolower( $_GET['input'] ); $len = strlen($input); $aResults = array(); if ($len) { for ($i=0;$i<count($aCountries);$i++) { if (strtolower(substr($aCountries[$i],0,$len)) == $input) $aResults[] = $aCountries[$i]; } } header("Content-Type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?> <results>"; for ($i=0;$i<count($aResults);$i++) echo" <rs>".$aResults[$i]."</rs>"; echo " </results> "; ?>

                              yeah, yeah, sue me, i forgot to initialize the array, i said it was untested...

                              anyway, tez, post your full code as it stands now!

                              stolzyboy

                                ok, just saw your post... change this block

                                while ($row = mysql_fetch_array($result)) 
                                {         
                                $aCountries[] = $row['jargon_term']; }

                                to this

                                while ($row = mysql_fetch_array($result)) 
                                {         
                                echo $row['jargon_term'] . "<br>"; }

                                does that show your results??

                                stolzyboy

                                  well, i'm just trying to see if you are actually getting your results from the table... after that, you can worry about the creation of the array, if the array isn't being created, the lookup isn't going to work... and forgive me if i'm misunderstanding what you are asking or are trying to convey

                                  stolzyboy