Jump to content

help


seany123

Recommended Posts

im in need of a little help..

 

i have this page which is basically a friendslist page... it adds players to my friends list and also displays them...

 

my problem is everytime i add someone or whatever and get the echo... it stops showing the html (and php) friendslist.

 

i have to then reload the page to see it..

 

 

<?php
include("lib.php");
define("PAGENAME", "Friend's List");
$player = check_user($secret_key, $db);
$maxfriends = 100; //Maximum number of friends!
include("templates/private_header3.php");	
?>
<html> 
<head> 
<title>MafiaKillerz</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<link rel="stylesheet" href="/css/style.css" type="text/css" media="all" /> 
  
</head> 
<body alink="#cc9900" vlink="#cc9900" link="#cc9900"> 

<div id="holder"> 
<div id="left_c"><div class="g_content"><h3>  Friend List</h3><div class="g_text">	<table width='100%'> 
	<tr> 
		<td width='10%'>ID</td> 
		<td width='31%'>Mobster</td> 
		<td width='12%'>Level</td> 
		<td width='12%'>Online</td> 
		<td width='22%'>Actions</td>
	</tr> 	
<?php
switch($_GET['act']){
default:
	$query=$db->execute("select * from `friendlist` where `uid`=?",array($player->id));
	while($friend = $query->fetchrow()) 
	{ //start looping $query!
		$getfriend=$db->execute("select * from `players` where `id`=?",array($friend['fid']));
		$getfriends=$db->execute("select * from `friendlist`");
		$friend2=$getfriends->fetchrow();
		$friend1=$getfriend->fetchrow();
		$friend=$friend1['username'];
		$friendid=$friend2['id'];
    echo "<tr>"; 
echo"<td>".$friend1['id']."</td>"; 
echo "<td><a href=\"profile.php?id=" . $friend1['username'] . "\">";
if ($friend1['banned'] >= 1)
    {
    echo "<b>[b] </b>"; 
    echo "<STRIKE>" .$friend1['username']. "</STRIKE></td>";
    }
    else if ($friend1['ncolor'] >= 1)
    {
echo "<b><font color=\"$color\">".$friend1['username']."</font></b>";
    }
    else if($friend1['staff'] >= 1)
    { 
    echo "<b><font color=\"Red\">".$friend1['username']."</font></b>";
    }
    else if($friend1['rm'] >= 1)
    {
    echo "<b><font color=\"Yellow\">".$friend1['username']."</font></b>";
    }
    else
    {
    echo "<font color=\"CC9900\">".$friend1['username']."</font>";    
    }
			echo "<td>" . number_format($friend1['level']) . "</td>\n";
			if ($friend1['last_active'] >= Time()-1200)
    {
    echo "<td><font color=\"limegreen\">Online</font></td>";
    }
    else
    {
    echo "<td><font color=\"red\">Offline</font></td>";
    }
echo "<td>[<a href=\"friendlist.php?act=delete&fid=$friendid\">DELETE FRIEND</a>]</td>";
	}
	break;

echo"</tr>"; 	
echo"<tr>"; 
echo"<td colspan=\'3\' align=\'left\'><a href=\'/friendlist/-25.php\'><< Previous</a></td>";
echo"<td colspan=\'3\' align=\'right\'><a href=\'/friendlist/25.php\'>Next >></a></td>"; 
echo"</tr>"; 
echo"</table>"; 
echo"</div></div></div> </div> </body></html>";

case 'add':
	if(!isset($_GET['user'])){
		header("location: friendlist.php");
	}else{
		$query=$db->execute("select * from players where `id`=?",array($_GET['user']));
		if($query->recordcount() == 0){
			echo "sorry, that user doesn't exist!";
		}elseif($_GET['user'] == $player->id){
			echo "you can't add yourself!";
		}else{
			$query2=$db->execute("select * from `friendlist` where `uid`=?",array($player->id));
			$numoffriends=$query2->recordcount();
			if($numoffriends == $maxfriends){
				echo "sorry, you already have $numoffriends you can't have any more!";
			}else{
				$query3=$db->execute("select * from `friendlist` where `uid`=? and `fid`=?",array($player->id, $_GET['user']));
				if($query3->recordcount() > 0){
					echo "sorry, that user is already your friend!";
				}else{
					$insert['uid'] = $player->id;
					$insert['fid'] = $_GET['user'];
					$query4=$db->autoexecute('friendlist', $insert, 'INSERT');
					if($query4){
						echo "friend added!";
					}
					else
					{
						echo "error! contact an administrator!";
					}
				}
			}
		}
	}
	break;

case 'delete':
	if(!isset($_GET['fid'])){
		header("location: friendlist.php");
	}else{
		$query=$db->execute("select * from `friendlist` where `id`=?",array($_GET['fid']));
		$friend1=$query->fetchrow();
		if($friend1['uid'] != $player->id){
			echo "sorry, this is not your friend!";
		}else{
			$query2=$db->execute("DELETE FROM `friendlist` WHERE `id`=?", array($_GET['fid']));
			if($query2){
				echo "Friend removed!";
			}else
			{
				echo "ERROR!";
			}
	}
	break;
}
}
?>	

 

 

i know my code is very scruffy so i apologise for that in advance...

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.