chaoswar4u Posted February 10, 2010 Share Posted February 10, 2010 In my attempt to reduce server load im now down to my last issue. I have a few things that are loaded via the header thus every page load a query is loaded per addional info. I wanting to get this information updated via the use of sessions but unsure how to go about it. Here is 1 or the queries that load. $fivgz=$db->query("SELECT gangNAME, gangID FROM gangs ORDER BY gangRESPECT DESC LIMIT 3"); while($r=$db->fetch_row($fivgz)) { print "[size=1]<a href='gangs.php?action=view&ID={$r['gangID']}'>{$r['gangNAME']}<a> [/size]";[code] Im still unsure if the limits regarding sessions and the like. How would you session this. I have the updates part sorted as per the help from fbiss on a past post however im stuck on this. The main reason is the query pulling a limit 3. All my attempts have failed with just showing one session result and not the 3 that are required. Many thanks in advance for any help. Quote Link to comment Share on other sites More sharing options...
Dayo Posted February 11, 2010 Share Posted February 11, 2010 you could do something like this if (!isset($_SESSION['uGang'])) { $fivgz=$db->query("SELECT gangNAME, gangID FROM gangs ORDER BY gangRESPECT DESC LIMIT 3"); while($r=$db->fetch_row($fivgz)) { $_SESSION['uGang'] = "[size="1"]<a href='gangs.php?action=view&ID={$r['gangID']}'>{$r['gangNAME']}<a> [/size]";} } else {echo $SESSION['uGANG'];} this probly can be done a better (more secure way ... not sure im no hacker but your storing html data then echo'in it so i spose there is an issue there) please note this may not work, i did itwhile on break at work on a dogey keyboard Quote Link to comment Share on other sites More sharing options...
chaoswar4u Posted February 12, 2010 Author Share Posted February 12, 2010 No dont work. Quote Link to comment Share on other sites More sharing options...
chaoswar4u Posted February 12, 2010 Author Share Posted February 12, 2010 No dont work. Quote Link to comment Share on other sites More sharing options...
fbiss Posted February 12, 2010 Share Posted February 12, 2010 No dont work. change $SESSION['uGANG'] to $_SESSION['uGANG'] at the end you may want to consider reading up on file caching instead Quote Link to comment Share on other sites More sharing options...
Dayo Posted February 12, 2010 Share Posted February 12, 2010 oh yea, stupid keyboard :wacko: Quote Link to comment Share on other sites More sharing options...
chaoswar4u Posted February 14, 2010 Author Share Posted February 14, 2010 Still cannot get this to work. All I can manage to do is get it to session one result but not the combonation of the limit 3 results. e.g top 3 members. Any ideas folks?? Quote Link to comment Share on other sites More sharing options...
Dayo Posted February 14, 2010 Share Posted February 14, 2010 try this then $_SESSION['uGang']=''; if (!isset($_SESSION['uGang'])) { $fivgz=$db->query("SELECT gangNAME, gangID FROM gangs ORDER BY gangRESPECT DESC LIMIT 3"); while($r=$db->fetch_row($fivgz)) { $_SESSION['uGang'] =$_SESSION['uGang']."[size="1"]<a href='gangs.php?action=view&ID={$r['gangID']}'>{$r['gangNAME']}<a> [/size]";} } else {echo $_SESSION['uGANG'];} Quote Link to comment Share on other sites More sharing options...
fbiss Posted February 15, 2010 Share Posted February 15, 2010 try this then $_SESSION['uGang']=''; if (!isset($_SESSION['uGang'])) { $fivgz=$db->query("SELECT gangNAME, gangID FROM gangs ORDER BY gangRESPECT DESC LIMIT 3"); while($r=$db->fetch_row($fivgz)) { $_SESSION['uGang'] =$_SESSION['uGang']."{$r['gangNAME']} ";} } else {echo $_SESSION['uGANG'];} thats going to make it never use the Session Try this if (empty($_SESSION['topgangs'])) { $_SESSION['topgangs']=''; $fivgz=$db->query("SELECT gangNAME, gangID FROM gangs ORDER BY gangRESPECT DESC LIMIT 3"); while($r=$db->fetch_row($fivgz)) { $_SESSION['topgangs'].= "[size="1"]<a href='gangs.php?action=view&ID={$r['gangID']}'>{$r['gangNAME']}<a>[/size] "; } } echo $_SESSION['topgangs']; Quote Link to comment Share on other sites More sharing options...
chaoswar4u Posted February 17, 2010 Author Share Posted February 17, 2010 Gee ive tried every example on here and not one has worked. Please test before posting to ensure it works. If any example here does work then please say so as it then could be a fault my end. Quote Link to comment Share on other sites More sharing options...
fbiss Posted February 17, 2010 Share Posted February 17, 2010 my above post was fixed, this should work for you. Quote Link to comment Share on other sites More sharing options...
chaoswar4u Posted February 19, 2010 Author Share Posted February 19, 2010 Thanks fbiss worked that time. Just to ask though. Is there any security issues with doing such a thing? Quote Link to comment Share on other sites More sharing options...
fbiss Posted February 19, 2010 Share Posted February 19, 2010 no.. now if u were using that session to save something back into the database or file system.. then yea maybe. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.