Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how can i get result from html form page

    Hi.. how can i get result from html form page when i will search for any people or their friends name? like if i search for "Pavel".. it will show that "Pavel is friend of Roni and Liton". and if i search for "Rana" then php link file will print that "Rana have 4 friend and he have 1 common friend (Jibon) with Nandini". help me plz asap.
    PHP Code:
    <?php
           
    # Function: finfCommon

        
    function findCommon($current$arr) {
            
    $cUser $arr[$current];
            unset(
    $arr[$current]);
            foreach (
    $arr As $user => $friends) {
                
    $common = array();
                
    $total = array();
                foreach (
    $friends As $friend) {
                    if (
    in_array($friend$cUser)) {
                        
    $common[] = $friend;
                    }
                }
                
    $total count($common);
                
    $add = ($total != 1) ? 's' '';
                
    $final[] = "<i>{$current} has {$total} friend{$add} in common with {$user}.</i>";
            }
            return 
    implode('<br />'$final);
        }

    # Array of users and friends
        
    $Friends = array(
            
    "Rana" => array("Pothik""Zaman""Tanmoy""Jibon"),
            
    "Nandini" => array("Bonna""Shakib""Kamal""Minhaj""Jibon"),
            
    "Roni" => array("Akbar""Anwar""Khakan""Pavel"),
            
    "Liton" => array("Mahadi""Pavel"),
            
    "Mamun" => array("Meheli""Tarek""Zaman")
        );

    # Creating the output value
        
    $output "<ul>";
        foreach (
    $Friends As $user => $friends) {
            
    $total count($friends);
            
    $common findCommon($user$Friends);
             
    $output .= "<li><u>{$user} has {$total}  friends.</u><br /><strong>Friends:</strong>";
            if (
    is_array($friends) && !empty($friends[0])) {
                
    $output .= "<ul>";
                foreach (
    $friends As $friend) {
                    
    $output .= "<li>{$friend}</li>";
                }
                
    $output .= "</ul>";
            }
            
    $output .= "{$common}<br /><br /></li>";
        }
        
    $output .= "</ul>";

    # Printing the output value
        
    print $output;
            
    ?>
    Last edited by Inigoesdr; 01-16-2011 at 11:07 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •