seany123 Posted May 15, 2009 Share Posted May 15, 2009 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 https://forums.phpfreaks.com/topic/158210-help/ Share on other sites More sharing options...
seany123 Posted May 15, 2009 Author Share Posted May 15, 2009 no one knows? Link to comment https://forums.phpfreaks.com/topic/158210-help/#findComment-834793 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 You have the HTML display in a switch statement. If $_GET['act'] is 'add' or a case in the switch, then the default case won't run. Link to comment https://forums.phpfreaks.com/topic/158210-help/#findComment-834796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.