vaulient2
New Member
- Mar 12, 2013
- 27
- 3
Code:
<?php
include('../core.php');
include('../includes/session.php');
$i = 0;
$output = "[";
$getem = mysql_query("SELECT * FROM messenger_friendships WHERE userid = '".$my_id."' OR friendid = '".$my_id."'") or die(mysql_error());
while ($row = mysql_fetch_assoc($getem)) {
$i++;
if($row['friendid'] == $my_id){
$friendsql = mysql_query("SELECT * FROM users WHERE id = '".$row['userid']."'");
} else {
$friendsql = mysql_query("SELECT * FROM users WHERE id = '".$row['friendid']."'");
}
$friendrow = mysql_fetch_assoc($friendsql);
$name = $friendrow['name'];
$id = $friendrow['id'];
$output = $output."{\"id\":".$id.",\"name\":\"".$name."\"},";
}
$output = substr_replace($output,"",-1);
$output = $output."]";
?>
/*-secure-
<?php echo $output; ?>
*/
This is the code that I'm trying to convert to replace the code below :
Code:
case 'recipients':
echo '/*-secure-' . LB;
echo '[';
$getBuddies = dbquery("SELECT receiver FROM messenger_friendships WHERE sender = '" . USER_ID . "'");
$i = 0;
while ($buddy = mysql_fetch_assoc($getBuddies))
{
if ($i > 0)
{
echo ',';
}
echo '{"id":' . $buddy['receiver'] . ',"name":"' . clean($users->id2name($buddy['receiver'])) . '"}';
$i++;
}
echo ']';
echo LB . ' */';
break;
I've been trying for some time now , but I keep failing , hopefully somrbody here would help me convert the top code to replace the 2nd code