driver_x Posted August 9, 2009 Share Posted August 9, 2009 i have a social website that has a friendslist. my problem is when i click on a profile that has over 1000 friends it takes a massive amount of time for the page to load. the code for the friendslist application is as follows (IS THIS CODE WRITTEN CORRECTLY? CAN IT BE SPED UP?) Thanks in advance Driver_x function ShowFriendList( $id ) { global $ID_PIC_DIR; global $ID_PIC_URL; global $site; $thumb_height = getParam('thumb_height'); $thumb_width = getParam('thumb_width'); $id = (int)$id; $friend_list_query = "SELECT `Profiles` .`ID`, `Profiles`.`NickName`, `Profiles`.`Pic_0_addon`, `Profiles`.`Picture` FROM `FriendList` LEFT JOIN `Profiles` ON (`Profiles`.`ID` = `FriendList`.`Profile` AND `FriendList`.`ID` = '$id' OR `Profiles`.`ID` = `FriendList`.`ID` AND `FriendList`.`Profile` = '$id') WHERE (`FriendList`.`Profile` = '$id' OR `FriendList`.`ID` = '$id' AND `FriendList`.`Check` = '1') ORDER BY `Profiles`.`Picture` DESC LIMIT 12"; $friend_list_res = db_res("$friend_list_query"); while ( $friend_list_arr = mysql_fetch_assoc( $friend_list_res ) ) { $src_dir = $ID_PIC_DIR . $friend_list_arr['ID'] . '_0_' . $friend_list_arr['Pic_0_addon'] . '.jpg'; if( file_exists( $src_dir ) ) { $src = "{$ID_PIC_URL}{$friend_list_arr['ID']}_0_{$friend_list_arr['Pic_0_addon']}.jpg"; } else { if( 'couple' == $friend_list_arr ) { $src = $ID_PIC_URL . 'couple.gif'; } else { $src_sex = ( 'male' == $friend_list_arr['Sex'] ) ? 'man.gif' : 'woman.gif'; $src = $ID_PIC_URL . $src_sex; } } $ret .= '<div class="thumbnail_block" style="width:' . $thumb_width . 'px; height:' . $thumb_height . '">'; $ret .= '<a href="' . $site['url'] . 'profile.php?ID=' . $friend_list_arr['NickName'] . '">'; $ret .=$friend_list_arr['NickName']; $ret .= '<img src="' . $site['images'] . 'spacer.gif" div class="thumb_profile1" style="width:' . $thumb_width . 'px; height:' . $thumb_height . 'px; background-image:url(' . $src . ');">';'px;" alt="' . $friend_list_arr['NickName'] . '" title="' . $friend_list_arr['Headline'] . '" />'; $ret .= '</a>'; $ret .= '</div>'; } return $ret; } Link to comment https://forums.phpfreaks.com/topic/169425-msql-speed-help/ Share on other sites More sharing options...
abazoskib Posted August 9, 2009 Share Posted August 9, 2009 duplicate post...http://www.phpfreaks.com/forums/index.php/topic,264116.0/topicseen.html stick to one thread per subject Link to comment https://forums.phpfreaks.com/topic/169425-msql-speed-help/#findComment-893925 Share on other sites More sharing options...
Recommended Posts