<?php
session_start();
$database="myfriend";
$userid=$_SESSION['user'];
mysql_connect("127.0.0.1","root","");
$db_found=mysql_select_db($database);
$sql="select fuserid from friends where userid='$userid';";
$result=mysql_query($sql);
$id=0;
$users=array();
?>
<body >
<center>
<p> your friends list:</p>
<?php
while($db_field=mysql_fetch_assoc($result))
{
?>
<a href="displayprofile.php" id='$id' onclick="validate(this)"><?php print $db_field['fuserid']."<br><br>";?></a>
<?php
$users[$id]=$db_field['fuserid'];
$id=$id+1;
}?>
<head script type="javascript/text">
<script>
function validate()
{
var id1=document.getElementById(</script><?php print $id ?><script>);
</script>
<?php
$_SESSION['id'] ?><script >=id1;
}
</script>
<?php
$id1=$_SESSION['id'];
$_SESSION['fuserid']=$users[$id1];
?>
thw o/p:name1
name2
..
depending on the selected name my code will be changing .Then how to know which item of while loop is selected at run time.plzz some one help this code is used in my project that displays profile of particular user depending on name.