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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.