| if (!isset($r_gr)) { // List of all photos
    $result = mysql_query("SELECT groups_id, groups_order, groups_type, groups_engname, groups_url, groups_dir FROM groups ORDER BY groups_order DESC");
    for ($i = 0; $i < mysql_num_rows($result); $i++) {
      list($groups_id, $groups_order, $groups_type, $groups_name, $groups_url, $groups_dir) = mysql_fetch_array($result);
      if ($groups_type == 1) {
        if ($i > 1) echo " ";
        echo "$groups_name
 ";
      } else
      if ($groups_type == 2)
        echo "   $groups_name
 ";
    };
    mysql_free_result($result);
  } else
  if (!isset($r_id)) { // List of all photos in this group
    echo "
 ";
    mysql_free_result($result);
    echo "";
  } else {
    $result = mysql_query("SELECT photos_id FROM photos WHERE groups_id = $r_gr");
    $result_num = mysql_num_rows($result);
    mysql_free_result($result);
    $result = mysql_query("SELECT photos_id, groups_id, photos_file, photos_source, photos_engname FROM photos WHERE groups_id = $r_gr ORDER BY photos_id LIMIT ".($r_id - 1).",1");
    if (mysql_num_rows($result) > 0) {
      list($photos_id, $groups_id, $photos_file, $photos_source, $photos_name) = mysql_fetch_array($result);
      echo "";
    $result = mysql_query("SELECT photos_id, groups_id, photos_file, photos_source, photos_engname FROM photos WHERE groups_id = $r_gr ORDER BY photos_id");
    for ($i = 1; $i <= mysql_num_rows($result); $i++) {
      list($photos_id, $groups_id, $photos_file, $photos_source, $photos_name) = mysql_fetch_array($result);
      echo "| ";
      echo " ";
      if ($i < mysql_num_rows($result))
        if ($i % 4 == 0) echo " ";
      if ($photos_name == "")
        echo "Photo $i";
      else
        echo "$photos_name";
      echo "
 |  ";
    };
    echo "
 | ";
      if ($r_id > 1) echo "";
      echo " | ";
      if ($photos_name == "")
        echo "Photo $r_id";
      else
        echo "$photos_name";
      echo " | ";
      if ($r_id < $result_num) echo "";
      echo " | 
  ";
    };
    mysql_free_result($result);
    echo "";
  };
?> |