if you post a lot of php code, please put it in [php] [/php] tags, this makes it easier to read.
there seems to be a logical problem in your code, I think you'd only want to set start to 0 if it is not set, and then proceed with the rest, right?
then you should close the bracket right here, or all your code will only be executed if start is not set:
if (!isset($start))
{
$start = 0;
}