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
https://forums.phpfreaks.com/topic/205049-trying-to-get-it-to-work/
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>";
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.