good day to everyone.
ive been having some troubles with the code a certain gentleman has posted about image gallery. here was the code he posted:

PHP Code:
<?
//************************************************************//
//                                                            //
//                PHP Slideshow v0.1                          //
//                Author: Brian Mahler                        //
//                Copyright (c) 2006 Brian Mahler             //
//                                                            //          
//************************************************************//
//
// CSS to position and change appearance
// Modify these settings to change the appearance of the page
//
?>
<!doctype html public "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
   <head>
      <title>PHP Slideshow v0.1 by Brian Mahler</title>
        <style type="text/css">
            body{
                background-color:#eee;
            }
            a:link, a:active, a:visited{
                text-decoration:none;
                color: #000;    
            }
            a:hover{
                color: #bbb;    
            }
            table#images{ /* Includes PageNav,ImageNav and Image */
                margin:auto;
            }
            td#copy{
                font-family: times;
                font-size:8pt;
            }
            Table#nav{ /* Navigation table */
                    
            }
            img#view{
                 
            }
            
        </style>
    </head>
    <body>
<?
//Definitions
//
//To change the number of thumbnails on a page, simply change the number  below
//
define("PER_PAGE",8);


//---------------------------------------------Do not Edit below this line-----------------------------------------------

//Get the path to the current directory
$z = split('/', $_SERVER['SCRIPT_FILENAME']);
$thisname = $z[count($z)-1];
$path = str_replace($thisname, '', $_SERVER['SCRIPT_FILENAME']);

//Define allowed file extensions
$allowed = array('jpg','gif','png');

//Read through the directory and find all files with proper file extensions
$dir = dir($path);
while ($file = $dir->read()) {
    if (($file != '.') && ($file != 'CVS') && ($file != '..')) {
        $file_size = filesize($path . $file);
        $file_extension = file_ext($file);
        if(!is_dir($path . $file) && isset($file_extension) && in_array($file_extension, $allowed)) {
            $images[] = array('name' => $file,
                              'size' => $file_size);
        }     
    }
}

//Check for images present in the directory
$count = count($images);
if ($count < 1){
    die('<center>No images present in current directory</center>');
}

//Calculate the number of pages
$pages = ceil($count / PER_PAGE);

//Get the current page

if (!isset($_GET['page'])){
    $current_page = 1;
}else{
    $current_page = $_GET['page'];
}

//Page Navigation
if ($current_page == 1) {
     $next = $current_page + 1;
    $pagehtml = '<b>Page ' . $current_page . ' of ' . $pages . '</b> | <a class="navi" href="index.php?page=' . $next . '">Next Page &gt;</a>';
}elseif ($current_page == $pages){
     $back = $current_page - 1;
    $pagehtml = '<a class="navi" href="index.php?page=' . $back . '">&lt; Previous Page</a> | <b>Page '  . $current_page . ' of ' . $pages . '</b>';             
}else{
    $next = $current_page + 1;
    $back = $current_page - 1;
     $pagehtml = '<a class="navi" href="index.php?page=' . $back . '">&lt; Previous Page</a> | <b>Page '  . $current_page . ' of ' . $pages . '</b> | <a class="navi" href="index.php?page=' . $next . '">Next Page &gt;</a>';
}


//Build the thumbnail navigation table
$y = $current_page * PER_PAGE;
$start = $y - PER_PAGE + 1;
$image_nav = '<table width="500px" id="nav"><tr>';
for ($x=$start; $x<=$y; $x++){
     if ($x <= $count){
         $url = $images[$x -1]['name'];
        $image_nav .= '<td align="center" valign="center" width="12.5%"><a href="index.php?page=' . $current_page . '&id=' . $x . '"><img src="' . $url . '" border="0" width="60px"></a></td>';
        
    }
}
$image_nav .= '</tr></table>';

//The image to be shown
$image_view = $_GET['id'];
if (!isset($_GET['id'])){
    $image_view = $current_page * 8 - 7;
}
$image = '<img id="view" src="' . $images[$image_view - 1]['name'] . '" width="512px">'; 

$copy = 'PHP Slideshow v0.1 &copy;2006 Brian Mahler';

//Display the slideshow
echo '<table id="images" width="500px" border="0" cellpadding="2px">';
echo '<tr><td align="center">' . $pagehtml . '</td></tr><tr><td align="center">' . $image_nav . '</td></tr><tr><td id="pic" align="center" valign="center" style="padding:2px;">' . $image . '</td></tr>';
echo '<tr><td id="copy" align="center">' . $copy . '</td></tr>';
echo '</table>';

//function to get file extension of files
function file_ext($file) {
    $extension = split("[.]", $file);
    $ext_file = $extension[count($extension)-1];
    return strtolower($ext_file);
}
?>
    </body>
</html>
ive been trying to study the code yet still no luck.
my goal is:

1. go get the images loaded in their original size -(some of my images have small texts that people cant read em.)
2. get the images sorted by number -(the script displays the images in random order -_-)

anyhelp would be greatly appreciated. oh and im still a newbie in php. so please do give me a good and simple one. Thanks and good day.