extemer -17 Junior Poster Banned

Hello guys i learn something new so i thought to share it with you people.This tutorial is about when you search some data in a search bar and as you enter any key word e.g 'a' so it start looking for keywords starting with 'a' and highlight it.In this way entering full name e.g ahmed it highlight the name ahmed.i used jQuery for this purpose and little bit of styling for the highlight purpose.i have used inline scripting for the purpose of ease for you people but prefer external scripting as it is the more proficient way.Here the code


<style type="text/css">

#table1, #table1 tr, #table1 td 
	border: 1px solid #666;



<script type="text/javascript" src="jquery.js"></script> <!--  need jquery.js file-->

<script type="text/javascript">


	search2 =$(this).val();
	$("#table1 tr td").removeClass('highlight');
	 if(jQuery.trim(search2) != ''){
	 $("#table1 tr td:contains('" + search2 +"')").addClass('highlight');



echo '<p>Search : <input type="text" id="search1"  /></p>';

  $connect = mysql_connect("localhost","root",""); // change here

  $limit = 14;
  $last = 24;

  $sql = mysql_query("SELECT `id`, `name` FROM `stu_info` WHERE `id` > '$limit' AND `id` <   '$last'"); // change here

  echo "<br /><table id='table1'>";
  while($show = mysql_fetch_assoc($sql)) 
  echo	$id  = '<tr id="test"><td>'.$show['id'].'<br /></tr></td>'; //change here
  echo	$name  = '<tr><td>'.$show['name'].'</tr></td>'; //change here
  echo "</table></p>";



If you people have any Question regarding this you can ask.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.