Monkuar Posted July 15, 2009 Share Posted July 15, 2009 i have a mod that it put's a image next to a users name in the viewforum.php (im using punbb btw) but nonethless this is simple php/mysql that fails me: //If there's a last poster $result4 = $db->query('SELECT imgaward FROM users WHERE username="'.($cur_topic['last_poster']).'" ') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); $post_user = $db->fetch_assoc($result4); // Image Award Mod Block Start //figure out the size of the award (Name of award should be in teh form: Test_Award_100x20.png ... where png is format, 100x20 is dimensions and Test_Award is name of award (seen in admin interface) $lol23=$post_user['imgaward']; if ($post_user['imgaward'] == "") { $lol123 = ""; } else { $lol123 = "<img src='img/stars/$lol23'>"; } So im selecting imgaward where username=lastpost.. bla bla. That is not good tho, because then when i do that, I have like 20 topics in 1 forum and it just runs 20 freaking query's and checks every user and crap, how is this possible so i can get information from the topics table or something so it doesnt have 100queries run each time u refresh your viewforum page, example: Isn't there a way I can run that query just once and put my variable $lol123 next to the username so it works?? ~~~~_~_~_~_~_~ Thanks, if u got msn mine is nick445617@Hotmail.com please add me or post yours.. i really need im offering ftp access and everything!! Thanks..1 XD Quote Link to comment https://forums.phpfreaks.com/topic/166019-this-thing-is-killing-my-database/ Share on other sites More sharing options...
ignace Posted July 15, 2009 Share Posted July 15, 2009 You need to go up higher in the chain and render the topics yourself using a join to add the last_poster data to your topics data SELECT * FROM topics, users WHERE topics.last_poster = users.id Quote Link to comment https://forums.phpfreaks.com/topic/166019-this-thing-is-killing-my-database/#findComment-875656 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.