Jump to content

Displaying foreach array results over multiple pages..


mkosmosports

Recommended Posts

Alright, Ive gotten this far:

if(isset($_GET['page'])) //If there is a page available

{

    $pageNum = $_GET['page'];

}

 

$trcount=0; //Number of loop results variable

foreach($trarray as $value) //This is the loop on the main array

{

$pid = $value['id'];

if(isset($_GET['l']) && $_GET['l'] == "2")

{

$date = substr("{$value['date']}",0,4);

$datemon = substr("{$value['date']}",4);

$shmon = $_SESSION['months'][$datemon][0];

}

else

{

$date = $value['date'];

$shmon = $_SESSION['months'][$date][0];

}

    $pos = $value['pos'];

    $nickname = $value['nickname'];

    $toteam = $value['toteam'];

    $fromteam = $value['fromteam'];

    $status = $value['status'];

    $sum = $value['sum'];

 

if ($date == $mon) //Only looking to retrieve info from a specific month

{

$trcount++; //Counting number of loop results

if (intval($sum) && $sum > "5000000")

{

echo("<tr style=\"background-color: #F5AA19; font-size: 10px\"><td align=\"center\">$shmon</td><td align=\"center\">$pos</td><td><a href=\"mainstats.html?l=3&player=$pid\"><b>$nickname</b></a></td><td>$fromteam</td><td style=\"font-weight: bold\">$toteam</td><td>$status</td><td><b>$sum</b></td></tr>");

}

else

{

echo("<tr style=\"font-size: 10px\"><td align=\"center\">$shmon</td><td align=\"center\">$pos</td><td><a href=\"mainstats.html?l=3&player=$pid\"><b>$nickname</b></a></td><td>$fromteam</td><td style=\"font-weight: bold\">$toteam</td><td>$status</td><td>$sum</td></tr>");

}

}

}

$maxpage = ceil($trcount/70); //See how many pages are needed based on number of results returned by array

$self = $_SERVER['PHP_SELF'];

 

echo("</table>");

 

if($trcount >= 70) //Only show the page links if there are more than 70 array results

{

echo("<div style=\"margin: 10px 0px; text-align: center\">");

for($page = 1; $page <= $maxpage; $page++)

{

      echo("<a class=\"trmonsel\" href=\"$self?type=transfers&mon=$mon&page=$page\">page: $page</a>");

}

}

echo("</div></div>");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.