<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 11/13/2015
	
	include ("check_session.php");

	$query = "SELECT head_name FROM " . BWB_TABLE_PREFIX . "head ORDER BY head_name DESC";
//	echo $query;
	$result = $bwb_dbh->query($query);
	$row = $result->fetch(PDO::FETCH_ASSOC);
	$head_name = $row["head_name"];
	
	$index = array();
	$i = 1;
	$index[0] = substr($head_name, strlen("head"));
	while ($row = $result->fetch(PDO::FETCH_ASSOC))
	{
		$head_name = $row["head_name"];
		$index[$i] = substr($head_name, strlen("head"));
		$i++;
	}
	sort($index);
	if (is_numeric($index[$i-1]))
		$next_index = $index[$i-1] + 1;
	else
		$next_index = 1;
		
	echo $next_index;
?>