Login     Sign up
Mutual friends
arizon efendi (@arizon)
Join date: Aug 26th 2010
Community posts: 145
View Profile
Send Message

you are god of php. your script work oke. thanks falcone.

165 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

well, the 'master' and 'god' found an error

[code]
if ( ($client['id']) && ($client['id'] != ($owner['id']) )) {

    $res = sql_query("SELECT u.* FROM `".tb()."friends` as f1 inner join `".tb()."friends` as f2 on f1.fid = f2.fid left join `".tb()."accounts` as u  on f1.fid=u.id where f1.uid={$owner['id']} and f2.uid={$client['id']} ".dbhold('f1')." ORDER BY f1.created DESC LIMIT 30");
    $mfs = sql_counts($res);
    $output = '';
    while ($row = sql_fetch_array($res)) {
        $output .= avatar($row);
    }
    if ($mfs > 0) {
    $mfstext = ($mfs == 1)?t(' friend in common'):t(' friends in common');  
    ass(array('title'=>t('Mutual Friends'), 'content' => '<div class="toolbar"><span style="float:left">'.$mfs.$mfstext.'</span><span style="float:right">'.url('u/'.$owner['username'] .'/mutualfriends',t('See all')).'</span></div><div style="clear:both;"></div>'.$output));
    }

}
[/code]

otherwise you get an error if you are not logged in.

165 months ago
arizon efendi (@arizon)
Join date: Aug 26th 2010
Community posts: 145
View Profile
Send Message

oh yea..... i have look my network.....

hahahahaha

i got error

SQL query error!
Error infomation:[SQL]
SELECT u.* FROM jcow_friends as f1 inner join jcow_friends as f2 on f1.fid = f2.fid left join jcow_accounts as u on f1.fid=u.id where f1.uid=147 and f2.uid= ORDER BY f1.created DESC LIMIT 30

[Error]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY f1.created DESC LIMIT 30' at line 1

You can get help by sending this infomation to us: [url]http://jcow.net[/url]

165 months ago
arizon efendi (@arizon)
Join date: Aug 26th 2010
Community posts: 145
View Profile
Send Message

done..the error finish. thanks again "god php".

165 months ago
Jordi Torres (@palsweb)
Join date: Oct 20th 2010
Community posts: 70
View Profile
Send Message

wai 2 codes ???

165 months ago
Jordi Torres (@palsweb)
Join date: Oct 20th 2010
Community posts: 70
View Profile
Send Message

2 codes in u module??? please help

165 months ago
Jordi Torres (@palsweb)
Join date: Oct 20th 2010
Community posts: 70
View Profile
Send Message

Mutual friendsnew function in u.module.php

Code
function mutualfriends($url = 0) {
global $client, $apps, $uhome,$ubase, $current_sub_menu, $offset, $num_per_page, $page;
$profile = $this->settabmenu($url, 1,'u');
$current_sub_menu['href'] = 'u/'.$url.'/friends';

// Mutual friends
$output = '<ul class="small_avatars">';
$res = sql_query("SELECT u.* FROM ".tb()."friends as f1 inner join ".tb()."friends as f2 on f1.fid = f2.fid left join ".tb()."accounts as u on f1.fid=u.id where f1.uid={$profile['id']} and f2.uid={$client['id']} ORDER BY f1.created DESC LIMIT $offset, $num_per_page");
while ($row = sql_fetch_array($res)) {
$output .= '<li>';
$output .= '<span>'.url('u/'.$row['username'], $row['username']).'</span> '.avatar($row);
$output .= '</li>';
}
$output .= '</ul>';

// pager
$res = sql_query("select count(*) as total from ".tb()."friends as f1 inner join ".tb()."friends as f2 on f1.fid = f2.fid where f1.uid={$profile['id']} and f2.uid={$client['id']} ".dbhold() );
$row = sql_fetch_array($res);
$total = $row['total'];
$pb = new PageBar($total, $num_per_page, $page);
$pb->paras = $ubase.'u/'.$profile['username'].'/friends';
$pagebar = $pb->whole_num_bar();
$output .= $pagebar;

section(
array('title'=>t('Mutual Friends'),
'content'=>$output)
);
}

added some code in the function show_sidebar

before

Code
//friends

[b]AND THIS WHERE ???[/b]

Code
// Mutual friends
$res = sql_query("SELECT u.* FROM ".tb()."friends as f1 inner join ".tb()."friends as f2 on f1.fid = f2.fid left join ".tb()."accounts as u on f1.fid=u.id where f1.uid={$owner['id']} and f2.uid={$client['id']} ".dbhold('f1')." ORDER BY f1.created DESC LIMIT 30");
$output = '';
while ($row = sql_fetch_array($res)) {
$f = 1;
$output .= avatar($row);
}
ass(array('title'=>t('Mutual Friends'), 'content' => '<div class="toolbar">'.url('u/'.$owner['username'] .'/mutualfriends',t('See all')).'</div>'.$output));

165 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

the first code is a function that you have to insert in the u class.

the second code you have to insert into the existing function show_sidebar

before lines
[code]
// friends
$res = sql_query("SELECT u.* FROM ".tb()."friends as f left join ".tb()."accounts as u on u.id=f.fid where f.uid={$owner['id']} ".dbhold('f')." ORDER BY f.created DESC LIMIT 30");
$output = '';
while ($row = sql_fetch_array($res)) {
$f = 1;
$output .= avatar($row);
}
ass(array('title'=>t('Friends'), 'content' => '<div class="toolbar">'.url('u/'.$owner['username'] .'/friends',t('See all')).'</div>'.$output));

[/code]

165 months ago
Jordi Torres (@palsweb)
Join date: Oct 20th 2010
Community posts: 70
View Profile
Send Message

Very nice its work fine....thanks for all !!!

165 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

i added an extra line in the function mutualfriends

[code]
need_login();
[/code]

after the line with the globals.

164 months ago
jacky loon (@jack41)
Join date: Nov 9th 2010
Community posts: 87
View Profile
Send Message

Its will be a great feature but has created confusion in putting the new code. can u please put a correct final code?
Thank you.

164 months ago
Thakim (@thakim83)
Join date: Oct 8th 2010
Community posts: 87
View Profile
Send Message

Any help with this code guys? I keep getting errors when I include the Mutual friend function. Please help

164 months ago
Prev 1 2 3 4 5 Next