Hey everyone, i'm kinda stuck right now. I have top links that I would like to show on my main page. 1-20 at the top of my main page and 21-40, the thing is... I have no clue on how to split up the links. I would like for it to look exactly like how this site has it. http://www.bootyarcade.com/ function display_top_links($base_url,$sorttoplinks,$maxtoplinks,$realurl){ if ($sorttoplinks ==1) { //old dayin method //$orderby = "ORDER BY dayin DESC"; // //new dayin24 method // //hap@moonbugstudio.com $orderby = "ORDER BY dayin24 DESC"; } elseif ($sorttoplinks ==2) $orderby = "ORDER BY totalin DESC"; elseif ($sorttoplinks ==3) $orderby = "ORDER BY websitename ASC"; else $orderby = "ORDER BY RAND()"; $sql_query = "SELECT * FROM links WHERE linkstatus = 1 $orderby LIMIT $maxtoplinks"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $linkid = $row['websiteid']; $websitename = stripslashes($row['websitename']); $websiteurl = $row['websiteurl']; $websitedescription = stripslashes($row['description']); // Trims the link name down to 40 characters if (strlen($websitename)>25) $websitename = substr($websitename,0,25)."..."; $totalin = $row['totalin']; $dayin = $row['dayin']; // new hourly method -- hap $dayin24 = 0; // safety first for($i=0; $i<=23; $i++) // go through 'hour0' to 'hour23' { // ignore old hours $lastTimeData = 'lasthour'.$i; $lastTime = $row[$lastTimeData]; $diffTime = time() - $lastTime; if($diffTime < 86400) // 24 hours ago in seconds { $hourData = 'hour'.$i; $dayin24 += $row[$hourData]; } } // store the updated 24 hour count // remember time always moves forward // hap@moonbugstudio.com if($dayin24 != $row['dayin24']) { $sqlQuery = "update links set dayin24=$dayin24 where websiteid=$linkid"; $sqlResult = mysql_query($sqlQuery); } // end new 24 hour method if ($realurl ==1) $websitelink = "<a title=\"Day In: $dayin24 / Total In: $totalin\" href=\"$websiteurl\" target=\"_blank\" class=\"maintext2\">$websitename</a>"; else $websitelink = "<a title=\"Day In: $dayin24 / Total In: $totalin\" href=\"".$base_url."linkout.php?id=$linkid\" target=\"_blank\" class=\"maintext2\">$websitename</a>"; $content = $content.$websitelink."<br />"; } } return $content; } PHP: That is the functions, and to display the links where ever I want I use this code <?=display_top_links($base_url,$sorttoplinks,$maxtoplinks,$realurl);?> PHP: Also for reference, my site is www.GameFrat.com Thank you for any and all help! -Doug
Add another argument to your LIMIT clause and a new parameter to your display_top_links function: function display_top_links($base_url,$sorttoplinks,$maxtoplinks,$realurl,$firsttoplink=1){ $firsttoplink -= 1; $maxtoplinks -= $firsttoplink; if ($sorttoplinks ==1) { //old dayin method //$orderby = "ORDER BY dayin DESC"; // //new dayin24 method // //hap@moonbugstudio.com $orderby = "ORDER BY dayin24 DESC"; } elseif ($sorttoplinks ==2) $orderby = "ORDER BY totalin DESC"; elseif ($sorttoplinks ==3) $orderby = "ORDER BY websitename ASC"; else $orderby = "ORDER BY RAND()"; $sql_query = "SELECT * FROM links WHERE linkstatus = 1 $orderby LIMIT $firsttoplink,$maxtoplinks"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $linkid = $row['websiteid']; $websitename = stripslashes($row['websitename']); $websiteurl = $row['websiteurl']; $websitedescription = stripslashes($row['description']); // Trims the link name down to 40 characters if (strlen($websitename)>25) $websitename = substr($websitename,0,25)."..."; $totalin = $row['totalin']; $dayin = $row['dayin']; // new hourly method -- hap $dayin24 = 0; // safety first for($i=0; $i<=23; $i++) // go through 'hour0' to 'hour23' { // ignore old hours $lastTimeData = 'lasthour'.$i; $lastTime = $row[$lastTimeData]; $diffTime = time() - $lastTime; if($diffTime < 86400) // 24 hours ago in seconds { $hourData = 'hour'.$i; $dayin24 += $row[$hourData]; } } // store the updated 24 hour count // remember time always moves forward // hap@moonbugstudio.com if($dayin24 != $row['dayin24']) { $sqlQuery = "update links set dayin24=$dayin24 where websiteid=$linkid"; $sqlResult = mysql_query($sqlQuery); } // end new 24 hour method if ($realurl ==1) $websitelink = "<a title=\"Day In: $dayin24 / Total In: $totalin\" href=\"$websiteurl\" target=\"_blank\" class=\"maintext2\">$websitename</a>"; else $websitelink = "<a title=\"Day In: $dayin24 / Total In: $totalin\" href=\"".$base_url."linkout.php?id=$linkid\" target=\"_blank\" class=\"maintext2\">$websitename</a>"; $content = $content.$websitelink."<br />"; } } return $content; } PHP: If $firsttoplink is specified when calling display_top_links then the list will start there, otherwise it will start at the beginning as usual. $maxtoplinks should be used to specify the last one. So to do links 1 to 20: <?php $maxtoplinks = 20; print display_top_links($base_url,$sorttoplinks,$maxtoplinks,$realurl); ?> PHP: and to do links 21 to 40: <?php $firsttoplink = 21; $maxtoplinks = 40; print display_top_links($base_url,$sorttoplinks,$maxtoplinks,$realurl,$firsttoplink); ?> PHP: