Jump to content

Trying to get it to work


jsaknow

Recommended Posts

Hi..

Im trying to get some kind of frindlist script to work, but I cant :S

 

It get the ID from Friend-database and then the name from the user-database, but nomatter what I do, it only wanna show one one the list.

 

here is the whole code im trying to get working, hope you can help me.

<?php
session_start();
include "access.php";

if (!isset($_SESSION['bruger'])) 
{
echo "Ingen adgang";
die(); 
}
else
{
$bruger = $_SESSION['bruger'];	
}

$query = "SELECT * FROM combruger WHERE bruger = '$_SESSION[bruger]'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);


$query = "SELECT * FROM friends WHERE id = '$row[id]'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{

$query = "SELECT * FROM combruger WHERE id = '" . $row['fid'] . "'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
	{
	if (($row['status']=='1'))
		{
		$pic='pic/icons/online.png';
		}
		else
		{
		$pic='pic/icons/offline.png';
		}

	echo "<img class='onoffpic' src='$pic'>  <a href='index.php?page=profil&id=" . $row['id'] . "' target='_top'>" . ucfirst($row['bruger']) . "</a>";
	}
}
?>

 

Link to comment
Share on other sites

Now its working..

Just if someone want to see the working code:

 

<?php
session_start();
include "access.php";

if (!isset($_SESSION['bruger'])) 
{
echo "Ingen adgang";
die(); 
}
else
{
$bruger = $_SESSION['bruger'];	
}

$query = "SELECT * FROM combruger WHERE bruger = '$_SESSION[bruger]'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);


$query = "SELECT * FROM friends WHERE id = '" . $row['id'] . "'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{	
$query2 = "SELECT * FROM combruger WHERE id = '" . $row['fid'] . "'";
$result2 = mysql_query($query2);
$row2 = mysql_fetch_array($result2);

	if (($row2['status']=='1'))
		{
		$pic='pic/icons/online.png';
		}
		else
		{
		$pic='pic/icons/offline.png';
		}

echo "<img class='onoffpic' src='$pic'>  <a href='index.php?page=profil&id=" . $row2['id'] . "' target='_top'>" . ucfirst($row2['bruger']) . "</a><br>";
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.