Need a little help making my images clickable. I've tried everything and whenever i do the images break and won't show. The code was provided on the site and i was trying to add pagination to my page and now another error occurs with click the images and seing the images 

```
while( $file = readdir( $open ) ){

  $ext = strtoupper( pathinfo( $file, PATHINFO_EXTENSION ) );

  if( in_array( $ext, $allow ) ){

    $modifyTime = filemtime( $dir . $file );
    $list[ $modifyTime ] = $file;

  }
}

# reverse sort on key
krsort( $list );

$perPage  = 20;
$total    = count($list);
$pages    = ceil($total/$perPage);
$thisPage = isset($_GET['pg'])?$_GET['pg']-1:0;
$start    = $thisPage*$perPage;

echo "Page "; 

// show pages
for ($i=0;$i<$pages;$i++):

  if ($i==$thisPage) :
    print "&nbsp;".($i+1); 
  else :
    print "&nbsp;<a href='?pg=".($i+1)."'>".($i+1)."</a>"; 
  endif;

endfor;

// show images
$items = array_slice( $list, $start, $perPage );
foreach( $items as $image ){
  echo "<a href='$dir/$file'<br/> " . $image . "<br/><img width='200' height='200' src='" . $urlPath . $image . "'/><br/></";
}

closedir($open);  
?>

```