Hi folks, I need help with php coding below and see if a guru can help me to get this to work. I have a block of 7 top posters and I would like to add another row below it with another 7 top posters. So make it two row with 7 top posters each. Below is the existing code and picture of what it is right now. if($settings01['ShowTopPosters']) { $content .= '<br/><div class="option" align="center"><b>'._FCBTOPPOSTERS.'</b></div><br/>'.$OpTbl.''; $content01 = '<tr>'; $result=$db->sql_query('SELECT a.user_id, a.username, a.user_posts, a.user_avatar FROM '.$user_prefix.'_users a ORDER BY user_posts DESC LIMIT 0,7'); while(list($user_id, $username, $user_posts, $avatar) = $db->sql_fetchrow($result)) { if($settings01['ShowRanks02']) { for($j = 0; $j < count($ranksrow); $j++) { if($user_posts >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special']) { $poster_rank = $ranksrow[$j]['rank_title']; $rank_image = ($ranksrow[$j]['rank_image']) ? '<br /><img src="'.$ranksrow[$j]['rank_image'].'" alt="'.$poster_rank.'" title="'.$poster_rank.'" border="0" /><br />' : ''; } } } else {$rank_image = '';} if($settings01['ShowTopPostersAvatar']) { if(eregi("http://", $avatar)) { $content .= '<td align="center" width="10%" class="row1" '.$MouseOver01.'><a href="'.getlink("Private_Messages&mode=post&u=$user_id").'"><img src="'.$avatar.'" border ="0" width="32" height="32" alt="PM" title="'.$FCBlang['Private_Message'].': '.$username.'"/></a><br />'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.$rank_image.'</a></td>'; } elseif(eregi("/", $avatar)) {$content .= '<td align="center" class="row1" '.$MouseOver01.'><a href="'.getlink("Private_Messages&mode=post&u=$user_id").'"><img src="'.$MAIN_CFG['avatar']['gallery_path'].'/'.$avatar.'" border ="0" width="32" height="32" alt="PM" title="'.$FCBlang['Private_Message'].': '.$username.'"/></a><br />'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.'</a>'.$rank_image.'</td>'; } elseif(!$avatar) {$content .= '<td align="center" width="10%" class="row1" '.$MouseOver01.'><a href="'.getlink("Private_Messages&mode=post&u=$user_id").'"><img src="'.$MAIN_CFG['avatar']['gallery_path'].'/'.$MAIN_CFG['avatar']['default'].'" border ="0" width="32" height="32" alt="PM" title="'.$FCBlang['Private_Message'].': '.$username.'"/></a><br />'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.'</a>'.$rank_image.'</td>'; } else {$content .= '<td align="center" width="10%" class="row1" '.$MouseOver01.'><a href="'.getlink("Private_Messages&mode=post&u=$user_id").'" target="_blank"><img src="'.$MAIN_CFG['avatar']['path'].'/'.$avatar.'" border ="0" width="32" alt="PM" height="32" title="'.$FCBlang['Private_Message'].': '.$username.'"/></a><br />'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.'</a>'.$rank_image.'</td>';} $content01 .= '<td width="10%" colspan="1" align="center" class="row3"><a href="'.getlink("Your_Account&profile=$user_id").'" title="'.$FCBlang['Profile'].': '.$username.'"><b>'.$username.'</b></a></td>'; } else { $content .= '<td align="center" class="row1">'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.'</a>'.$rank_image.'</td>'; $content01 .= '<td width="10%" colspan="1" align="center" class="row3"><a href="'.getlink("Forums&file=profile&mode=viewprofile&u=$user_id").'" title="'.$FCBlang['Profile'].': '.$username.'"><b>'.$username.'</b></a></td>'; } } $content01 .= '</tr>'; $content .= '</tr>'.$content01.'</table>'; } Code (markup): I think that I need to change the limit to 0, 7 to 0, 14 but I am not sure about adding another row of another 7 posters below it. Any hint or suggestion are highly appreciated. Thanks
Yes, just change that number from 7 to 14. It tells MySQL how many records you want to be returned by query (from 0 to 14th). The rest of you code is written to handle any number of results.
Hello, We understood your problem, here is an example of doing it..plz take a look at it and implement it in your code. In this code currently 3 columns are made in a row and it fetches all your records.. <table width="100" border="0" cellpadding="5" cellspacing="0"> <?php $selectQueryEventImages = "SELECT * FROM tbl_eventimage WHERE eventId='$id'"; #echo $selectQueryEventImages; $resultQueryEventImages = mysql_query($selectQueryEventImages); $numRowsEventImages = mysql_num_rows($resultQueryEventImages); if($numRowsEventImages=="") { ?> <tr> <td class="txts" style="padding:5px;"><?php echo ("Record not available");?></td> </tr> <tr> <?php } else { $count=0; while($rowQueryEventImages=mysql_fetch_array($resultQueryEventImages)) { #die($id=$rowQueryEventImages['id']); $eventImageId=$rowQueryEventImages['imageName']; $pathEvent='eventImage/140X120/'.$eventImageId; if($count % 3==0) echo "</tr><tr>"; ?> <td style="padding-bottom:10px;padding-top:10px;" valign="top" class="tabs"><table width="100" border="0" cellspacing="0" cellpadding="0" style="border:1px #cccccc solid';"> <tr> <td width="100" align="center"><table width="100" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="30" align="center"><?php if(file_exists($pathEvent)) { echo ("<img src='eventImage/140X120/".$eventImageId."'/>"); } else { ?> <img src="../eventImages/default.jpg" width="75" height="75" /> <?php } ?> </td> </tr> </table></td> </tr> </table></td> <?php $count++; } } </tr> </table> Code (markup): to use it in your code.. change the query as you required and set limit to 14. and replace if($count % 3==0) echo "</tr><tr>"; with if($count % 7==0) echo "</tr><tr>"; Regards, Stylesofts Developing Team
Hi all, Thanks for your quick response. So I changed the limit to 14 but it displays on in one row. I can't get the 2nd row to create. Stylesofts, I am not very good at the code. Can you help with my code rather than giving me example? Should I can create another variable like $content02 = '<tr>';? Thanks a lot.
Try this if($settings01['ShowTopPosters']) { $content .= '<br/><div class="option" align="center"><b>'._FCBTOPPOSTERS.'</b></div><br/>'.$OpTbl.''; $content01 = '<tr>'; $result=$db->sql_query('SELECT a.user_id, a.username, a.user_posts, a.user_avatar FROM '.$user_prefix.'_users a ORDER BY user_posts DESC LIMIT 0,14'); $count=0; while(list($user_id, $username, $user_posts, $avatar) = $db->sql_fetchrow($result)) { $count++; if (count>=7) $content01 .= '</tr><tr>'; if($settings01['ShowRanks02']) { for($j = 0; $j < count($ranksrow); $j++) { if($user_posts >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special']) { $poster_rank = $ranksrow[$j]['rank_title']; $rank_image = ($ranksrow[$j]['rank_image']) ? '<br /><img src="'.$ranksrow[$j]['rank_image'].'" alt="'.$poster_rank.'" title="'.$poster_rank.'" border="0" /><br />' : ''; } } } else {$rank_image = '';} if($settings01['ShowTopPostersAvatar']) { if(eregi("http://", $avatar)) { $content .= '<td align="center" width="10%" class="row1" '.$MouseOver01.'><a href="'.getlink("Private_Messages&mode=post&u=$user_id").'"><img src="'.$avatar.'" border ="0" width="32" height="32" alt="PM" title="'.$FCBlang['Private_Message'].': '.$username.'"/></a><br />'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.$rank_image.'</a></td>'; } elseif(eregi("/", $avatar)) {$content .= '<td align="center" class="row1" '.$MouseOver01.'><a href="'.getlink("Private_Messages&mode=post&u=$user_id").'"><img src="'.$MAIN_CFG['avatar']['gallery_path'].'/'.$avatar.'" border ="0" width="32" height="32" alt="PM" title="'.$FCBlang['Private_Message'].': '.$username.'"/></a><br />'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.'</a>'.$rank_image.'</td>'; } elseif(!$avatar) {$content .= '<td align="center" width="10%" class="row1" '.$MouseOver01.'><a href="'.getlink("Private_Messages&mode=post&u=$user_id").'"><img src="'.$MAIN_CFG['avatar']['gallery_path'].'/'.$MAIN_CFG['avatar']['default'].'" border ="0" width="32" height="32" alt="PM" title="'.$FCBlang['Private_Message'].': '.$username.'"/></a><br />'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.'</a>'.$rank_image.'</td>'; } else {$content .= '<td align="center" width="10%" class="row1" '.$MouseOver01.'><a href="'.getlink("Private_Messages&mode=post&u=$user_id").'" target="_blank"><img src="'.$MAIN_CFG['avatar']['path'].'/'.$avatar.'" border ="0" width="32" alt="PM" height="32" title="'.$FCBlang['Private_Message'].': '.$username.'"/></a><br />'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.'</a>'.$rank_image.'</td>';} $content01 .= '<td width="10%" colspan="1" align="center" class="row3"><a href="'.getlink("Your_Account&profile=$user_id").'" title="'.$FCBlang['Profile'].': '.$username.'"><b>'.$username.'</b></a></td>'; } else { $content .= '<td align="center" class="row1">'.$FCBlang['Posts'].': <a href="'.getlink("Forums&file=search&search_author=$username").'" title="'.$FCBlang['Posts'].': '.$username.'">'.$user_posts.'</a>'.$rank_image.'</td>'; $content01 .= '<td width="10%" colspan="1" align="center" class="row3"><a href="'.getlink("Forums&file=profile&mode=viewprofile&u=$user_id").'" title="'.$FCBlang['Profile'].': '.$username.'"><b>'.$username.'</b></a></td>'; } } $content01 .= '</tr>'; $content .= '</tr>'.$content01.'</table>'; } Code (markup):