Jump to content
php.lv forumi

AJAX autocomplete + MySQL fīčā nau apskaidrība


Cibiņš

Recommended Posts

Kā īsti lai panāk šādu lietu:

 

formas laukā ievada vārdu - autocomplete izvada vārdu un uzvārdu, bet ja ievada uzvārdu tad izvada uzvārdu un vārdu (tipa autocomplete samaina vietām vārdu un uzvārdu atkarībā no tā kas ievadīts pirmais).

 

Patlaban ir tā ka ieraksta uzvārdu tad viņš izvada uzvārdu bet uz vārdu vispār po..

 

Mana draza šeit: http://www.adparts.lv/autocomplete.zip

 

include("common.php");
	if(isset($_POST['queryString'])) {
		$queryString = $_POST['queryString'];		
		if(strlen($queryString) >0) {
			$query = "SELECT name, surname FROM people WHERE name OR surname LIKE '$queryString%' LIMIT 10";
			$result = mysql_query($query) or die("ERROR connecting to database!");
				while($row = mysql_fetch_array($result)){
				echo '<li onclick="fill(\''.$row[name or surname].'\');">'.$row[name or surname].'</li>';                                         
     }
  }
  }

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...