aftab_jii Posted June 27, 2007 Share Posted June 27, 2007 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 The values RAPE110 and ABC Stal are from one table but two differnt columns 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.