| px | top | add code | search | signup | login | help |
<?php
//
// *** the list browser ***
//
// created by Van. D. Mouradian in may (or june, I don't remember exactly) 1999.
// you're welcome to use this script in personnal pages if you're a Star Wars addict (even if you're not, actually).
// please contact me for any commercial use.
// e-mail : van.mouradian@efrei.fr
//
// insert this script in your page with the following variables :
// $total = number of elements in the list
// $rank = current rank in the list
//
// we assume that the script will display 5 items per page
// hence : $rank_prev = $rank - 5; and $rank_forw = $rank + 5;
//
// the page is called "the_page.php3"
// you will need at least 6 pictures :
// "prev_button.gif" is the one to click to get 1 page back
// "no_prev_button.gif" is the unclickable version of the former, for the first page
// "indic_empty.gif" is the empty meter (displaying the elements not browsed yet)
// "indic_full.gif" is the meter that shows all the elements that have been browsed
// "next_button.gif" is the one to click to get 1 page forward
// "no_next_button.gif" is the unclickable version of the former, for the last page
//
echo "<CENTER>";
if ($rank_prev >= 0)
{ echo "<A HREF=\"the_page.php3?rank=$rank_prev\"><IMG SRC=\"prev_button.gif\" BORDER=\"0\" ALIGN=\"top\"></A>";
}
else
{ echo "<IMG SRC=\"no_prev_button.gif\" ALIGN=\"top\"";
}
$calibre = ceil($total/5);
$position = $rang/5+1;
$taille = 150; // size of the browser
$taille_pleine = $taille*$position/$calibre;
$taille_vide = $taille-$taille_pleine;
$ecart = $taille/$calibre;
$grad_pleine = floor($position);
$grad_vide = $calibre-$grad_pleine;
?><MAP NAME="indicator_full"><?php
for ($i = 1; $i <= $grad_pleine; $i++)
{ echo "<AREA SHAPE=\"rect\" COORDS=\"$ecart*($i-1), 22, $ecart*$i 30\" HREF=\"the_page.php3?rank=($i-1)*5\">";
}
echo "</MAP>";
?><MAP NAME="indicator_empty"><?php
for ($j = 1; $j <= $grad_vide; $j++)
{
echo "<AREA SHAPE=\"rect\" COORDS=\"$ecart*($j-1), 22, $ecart*$j, 30\" HREF=\"the_page.php3?rank=ceil(($j-1+$position)*5)\">";
}
echo "</MAP>";
echo "IMG SRC=\"indic_full.gif\" USEMAP=\"#indicator_full\" BORDER=\"0\" HEIGHT=\"30\" WIDTH=\"$taille_pleine\" ALIGN=\"top\">";
if ($taille_vide != 0)
{ echo "<IMG SRC=\"indic_empty.gif\" USEMAP=\"#indicator_empty\" BORDER=\"0\" HEIGHT=\"30\" WIDTH=\"$taille_vide\" ALIGN=\"top\">";
}
if ($rank_forw < $total_recherche)
{ echo "<A HREF=\"the_page.php3?rank=$rank_forw\" BORDER=\"0\" ALIGN=\"top\"><IMG SRC=\"next_button.gif\" BORDER=\"0\" ALIGN=\"top\"></A>";
}
else
{ echo "<IMG SRC=\"no_next_button.gif\" ALIGN=\"top\">";
}
echo "</CENTER>";
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.