Jump to content

this thing is killing my database..


Monkuar

Recommended Posts

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:

 

 

biulc2.jpg

 

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 [email protected] please add me or post yours.. i really need im offering ftp access and everything!! Thanks..1 XD

 

 

Link to comment
https://forums.phpfreaks.com/topic/166019-this-thing-is-killing-my-database/
Share on other sites

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.