Jquery data display from database

Hi Guys,

I am posting simple example of fetching data from database using jquery. This code display password stored in database using jquery instantly. You just need to call simple jquery function and it will return password as a response text.

First, you will create index.php in which you will copy this code. Set database connections on the top.

	$result1=mysql_query("select * from users_tb where id=1");

Include jquery file. You can download it from here.

<script language="javascript" src="jquery-1.2.6.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function displayPassword(id)
	var aurl='show_password.php?id='+id;
	var result = $.ajax({
	type: "GET",
	url: aurl,
	data: "stuff=1",
	async: false
<table width="100%" cellspacing="3" align="center" class="admin_form">
	<td nowrap="nowrap" width="30%" class="admin_form_label">
	<a href="javascript:void(0)" onclick="displayPassword(<?php echo $id; ?>)">Show Password</a></td>
				<td class="admin_form_field" id="password_td"><?php if(isset($_GET['pass']) && $_GET['pass']!="") echo $_GET['pass'];?>

Now our basic structure is complete. You need to create one more file. In the jquery function, request has been sent to show_password.php with database id. This file simply echo database user password.



$result=mysql_query("select * from users_tb where id='".$_GET["id"]."'");

echo $password;

More jquery stuff in next posts.

Enjoy it :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>