$value) { $data = array(); if ($value == "") { continue; } $value = rtrim($value); if ($row == 0) { $headers = explode($delim_field,$value); } else { $fields = explode($delim_field,$value); //break up the data foreach ($headers as $k => $v) { $fields[$k] = trim($fields[$k],'"'); $fields[$k] = str_replace("\"\"", "\"", $fields[$k]); $data[$v] = $fields[$k]; } if ($data[$field_id] == $id) { $template['current'] = $data; continue; } if ($template['current'] == ""){ $template['prev'] = $data; } elseif($template['current'] != "") { $template['next'] = $data; break; } } } //set the current image $template['current']['image'] = $template['current']["IMAGE_{$view}"]; //deal with 2nd image -- if it's not there, then go to next if ($view == 1 && trim($template['current']['IMAGE_2']) != '') { $template['next'] = $template['current']; $nextView = 2; } else $nextView = 1; //deal with first image if ($view == 1 && trim($template['prev']['IMAGE_2']) != '') { $prevView = 2; } elseif ($view == 2) { $template['prev'] = $template['current']; $prevView = 1; } else $prevView = 1; //create the new links if ($template['next'] == '') $template['current']['nextLink'] = "products.php"; else $template['current']['nextLink'] = "?id={$template['next'][$field_id]}&view={$nextView}"; if ($template['prev'] == '') $template['current']['prevLink'] = "products.php"; else $template['current']['prevLink'] = "?id={$template['prev'][$field_id]}&view={$prevView}"; //simple field replacment from the array $t = new Template(".", "remove"); $t->set_file(array("page" => "products.tpl.htm")); $t->set_var($template['current']); $t->parse("OUT","page"); $t->p("OUT"); ?>