mrcniceguy 5 Posting Whiz in Training

i have a script which i`m using in ma site,for friends system.
that if somebody accept me as friend,i appear in his friend list also he appears in my friends list.
That works fine.
Also when displaying the friend list is ok!!!(In which to all scripts i used serialize and unserialized functions.
My Question is how do i select a single record from the unserialized record.
Becoz i want to use it,display actions which where done with my friends(exmple:if he/she is in my friend list and he added photo,then i`ll be updated)
below is accepting request file

<?php

//Connect to the database server
include"config.php";


$loggain=$_SESSION['user'];
$logged_id=$_POST['logged_id'];//the one accpeting requests
$friend_id=$_POST['friend_id'];//the one to be added in the list
$accept=$_POST['accept'];
$reject=$_POST['reject'];
if(isset($accept)) {
    $query = mysql_query("SELECT * FROM request WHERE user = '$friend_id' AND friend = '$logged_id'");//this is the request table(panding to be accepted)
    if(mysql_num_rows($query) > 0) {
	
        $_query = mysql_query("SELECT * FROM profile WHERE id = '$friend_id'");//somebody profile including the friends column
      $_row = mysql_fetch_array($_query);
       $email=$_row['email'];
      $friends = unserialize($_row["friendss"]);
      $friends[] =$logged_id;      
                
      mysql_query("UPDATE profile SET friendss = '" . serialize($friends) . "' WHERE id = '$friend_id'");
      
      $_query = mysql_query("SELECT * FROM profile WHERE id = '$logged_id'");
      $_row = mysql_fetch_array($_query);
      
      $friends = unserialize($_row["friendss"]);
      $friends[] =$friend_id;      
                
      mysql_query("UPDATE profile SET friendss = '" . serialize($friends) . "' WHERE id = '$logged_id'");//
    }
		
	
 mysql_query("DELETE FROM request WHERE user = '$friend_id' AND friend = '$logged_id'");//delete after accepting.
 
 include"1.php";
 
 }

and this one is friend list file

<?php

 //Connect to the database server
 include"config.php";



$user=$_SESSION['user'];
$logged_id=$_SESSION['id'];
$count=0;
$query = mysql_query("SELECT friendss FROM profile WHERE id = '$logged_id'");
$count=mysql_num_rows($query);

$sum=0; 
while($row = mysql_fetch_array($query)) {
    $friends= unserialize($row["friendss"]);
    
    
    if(isset($friends[0])) {
      foreach($friends as $friend) {
        $_query = mysql_query("SELECT  *FROM profile WHERE id = '" . $friend . "'");
		$counta=mysql_num_rows($_query);
		$_row = mysql_fetch_array($_query);
		
$friend_id=$_row['id'];
$name=$_row['names'];
$email=$_row['emails'];
$country=$_row['countrys'];
$location=$_row['locations'];
$langu1=$_row['langu1s'];
$langu2=$_row['langu2s'];
$family=$_row['familys'];
$education=$_row['educations'];
$age=$_row['ages'];
$male=$_row['males'];
}
}
}

HELP ME IN THIS PLEASE)))

Be a part of the DaniWeb community

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