0
<html>
<head script type="javascript/text">
<script>
function validate()
{

var html=document.getElementById(<?php '$count1'?>);
<?php
session_start();
$_SESSION['fuserid']=?>="html"

}
</script>
</head>
</html>
<?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);
$count1=0;
while($db_field=mysql_fetch_assoc($result))
{  
     ?>
     <body>
     <a href="displayprofile.php" id=<?php =$count1; ?> onclick="validate(this)">
     <?php  print $db_field['fuserid']."<br>";

     ?>
     </a>
     </body>
     <?php
        $count1=$count1+1; 
     }




mysql_close();
?>

according to $db_field the displayprofile.php will chenge but whenever i am trying to use this code i am getting last $db_field variable ??can any one help to solve this problem.

Edited by Dani: Formatting fixed

Attachments
<?php
$database="myfriend";
session_start();
$userid=$_SESSION['fuserid'];
mysql_connect("127.0.0.1","root","");
$db_found=mysql_select_db($database);
$sql="select * from profiles where userid='$fuserid';";
$result=mysql_query($sql);
$db_field=mysql_fetch_assoc($result);
print $userid;
$petname=$db_field['petname'];
$hometown=$db_field['hometown'];
$dateofbirth=$db_field['dateofbirth'];
$college=$db_field['college'];
$favbooks=$db_field['favbooks'];
$languages=$db_field['languages'];
$interest=$db_field['interest'];


  print $petname; 
 print $hometown; 
 print $dateofbirth;
 print $college;  
print $favbooks; 

print $languages;
 print $interest;
?>
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by prasanna123
0
<?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];
    ?>

i used the above code and the o/p is :name1
name2
....
then how can i know which name is selected because depending on the selected name my code changes

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.