https://www.icyphoenix.com/viewtopic.php?f=26&t=3614&p=24308#p24308
-----------------------------------
KugeLSichA
Thu 14 Feb, 2008 23:32

Some Help for SQL Needed
-----------------------------------
Hi everybody,

I try to port a script into my Icy Phoenix and now i need your help.

The script uses other sql statements, and this is my problem. this is the original sql statement:
[spoiler][code]$sections_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}sections` WHERE `deleted` = 0 ORDER BY `name` ASC");
while ($sections_row = dbFetch($sections_ref))
{
  $seasons_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}seasons` " .
			  "WHERE `id_section` = {$sections_row['id']} AND `deleted` = 0 " .
			  "ORDER BY `submitted` DESC");
  while ($seasons_row = dbFetch($seasons_ref))
  {
    $main_tpl->set_var("I_ID_SEASON", $seasons_row['id']);
    $main_tpl->set_var("I_SECTION_NAME", $sections_row['name']);
    $main_tpl->set_var("I_SEASON_NAME", $seasons_row['name']);
    $main_tpl->parse("H_SEASON_DROPDOWN", "B_SEASON_DROPDOWN", true);
  }
}[/code][/spoiler]

and this is what i have done yet
[spoiler][code]$sql = "SELECT * FROM " . TOURNEY_SECTIONS_TABLE . "
	WHERE `deleted` = 0
	ORDER BY `name` ASC";
$result = $db->sql_query($sql);
$section_info = $db->sql_fetchrowset($result);
	for ($x = 0; $x < count($section_info); $x++)
	{
		$section_id = $section_info[$x]['name'];
	}

  $sql = "SELECT * FROM " . TOURNEY_SEASONS_TABLE . "
		WHERE `deleted` = 0
		ORDER BY `submitted` DESC";
	$result = $db->sql_query($sql);
	$season_info = $db->sql_fetchrowset($result);
	$season_select = '';
	$season_select .= '<form action="">';
	$season_select .= 'Select Season: <select name="season_id" size="1">';
	$season_select .= '<option value="0">-</option>';
	for ($x = 0; $x < count($season_info); $x++)
	{
		$season_select .= '<option value="' . $season_info[$x]['id'] . '">' . $section_info[$x]['name'] . ' ' . $season_info[$x]['name'] . '</option>';
	}
	$season_select .= '</select>';
	$season_select .= '<input type="submit" value="Go">';
	$season_select .= '</form>';
	
	$template->assign_vars(array(
		'SEASON_SELECT' => $season_select,
		)
	);[/code][/spoiler]

the problem is, that my code, select all seasons, correct, but the section name is not shown by all created options.

can somebody help me with that?


