Jump to content

Help: Multiple textfield autocomplete


aftab_jii

Recommended Posts

im working with a PHP form that reads values from a database and an AJAX code that autocompletes the values..

what i am having problem with is that each felt reads all the values from all the columns in the database..

take a look at the screen shoot

 

1.JPG

 

The values RAPE110 and ABC Stal are from one table but two differnt columns

 

2.JPG

 

3.JPG

 

I need help to sort out what i ha ve to do so that the textfields get/shows values that belong to the column

The PHP code where i define the column look like:

 

<td id="text">Mal artikkel:</td>
     <td>
     <input type="text" name="malartikkel" size="20" maxlength="40" value="<?php if (isset($_REQUEST['malartikkel'])) echo $_REQUEST['malartikkel']; ?>" />
	 <div id="hint"></div>
	 		 	<script type="text/javascript">
	 		 		new Ajax.Autocompleter("malartikkel","hint","server.php");
        </script>
	 </td>
     </tr>


<tr>
	<td id="text">Leverandørens navn:</td>
	  <td>
	  <input type="text" name="leverandorsnavn" size="40" maxlength="40" value="<?php if (isset($_REQUEST['leverandorsnavn'])) echo $_REQUEST['leverandorsnavn']; ?>" />
      <div id="hint"></div>
	 		 	<script type="text/javascript">
	 		 		new Ajax.Autocompleter("leverandorsnavn","hint","server.php");
        </script>
	  </td>

 

and the sql (which is defined in server.php) looks like:

 

$sql = "SELECT malartikkel, leverandorsnavn FROM varebest WHERE malartikkel LIKE '%" . $_POST['search'] . "%'" . " AND leverandorsnavn LIKE '%" . $_POST['search'] . "%'";
$rs = mysql_query($sql);

?>

<ul>

<? while($data = mysql_fetch_assoc($rs)){ ?>
    <? //echo stripslashes($data['malartikkel']);
         echo stripslashes($data['produktbeskrivelse']);
         echo stripslashes($data['malartikkel']);
?>
<? } ?>

</ul>

 

Link to comment
https://forums.phpfreaks.com/topic/57472-help-multiple-textfield-autocomplete/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.