<?php
/*
* SWG Resource Tracker
* Copyright (C) 2004 Enigma
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
function printComboBox($printSubmit, $prefix)
{
global $DB;
//, $prefix;
$query = "SELECT * FROM `category1`";
$DB->query($query);
$results = $DB->fetchall();
if ($printSubmit)
$output .= "<select name='{$prefix}category1' onChange='form.submit()'>
<option value=-1> </option>\n";
else
$output .= "<select name='{$prefix}category1'>
<option value=-1> </option>\n";
$key = "{$prefix}category1";
for ($i = 0; $i < count($results); $i++)
{
$output .= "<option value={$results[$i]['id']}";
if (isset($_REQUEST[$key]) && $_REQUEST[$key] == $results[$i]['id'])
$output .= " selected";
$output .= ">{$results[$i]['name']}</option>\n";
}
$output .= "</select>\n\n";
$x = 2;
$prevkey = "{$prefix}category" . ($x - 1);
$key = "{$prefix}category$x";
$selected = true;
while ($x < 7 && $_REQUEST[$prevkey] > 0 && $selected) // && (isset($_REQUEST[$key]) || $_REQUEST[$prevkey] > -1)
{
$query = "SELECT * FROM `category$x` WHERE `category`={$_REQUEST[$prevkey]}";
$DB->query($query);
$results = $DB->fetchall();
if (count($results) == 0)
break;
if ($printSubmit)
$output .= "<select name='$key' onChange='form.submit()'>
<option value='-1'></option>\n";
else
$output .= "<select name='$key'>
<option value='-1'></option>\n";
$selected = false;
for ($i = 0; $i < count($results); $i++)
{
$output .= "<option value='{$results[$i]['id']}'";
if (isset($_REQUEST[$key]) && $_REQUEST[$key] == $results[$i]['id'])
{
$output .= " selected";
$selected = true;
}
$output .= ">{$results[$i]['name']}</option>\n";
}
$output .= "</select>\n\n";
$x++;
$prevkey = "{$prefix}category" . ($x - 1);
$key = "{$prefix}category$x";
}
//Unset any variables after this point
while ($x < 7) // && (isset($_REQUEST[$key]) || $_REQUEST[$prevkey] > -1)
{
unset($_REQUEST[$prevkey]);
$x++;
$prevkey = "{$prefix}category" . ($x - 1);
$key = "{$prefix}category$x";
}
/*foreach ($_REQUEST as $key => $value)
{
if (!ereg("^{$prefix}", $key))
$output .= "<input type='hidden' name='$key' value='$value'>\n";
}*/
return $output;
}
?>