Page 1 of 1

Using a function within a function

Posted: Wed Jul 06, 2005 3:13 am
by Haller
Lo PPl,

Is it possible to use a function within a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.


Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;data&#1111;tarrif_type_duration]) * getitem(day_total)),
				1111;'var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duraithin setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; ((nction? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duratiossible to use a function within a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&ampossible to use a function within a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_ve the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_name], 
						"tarrif_type_start" => $sql->data[tarrif_type_start],
						"tarrif_type_end&quotethin setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

&lt;?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&ampunction within a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_name], 
						"tarrif_type_start" => $sql->data[tarrif_type_start],
						"tarrif_type_end" => $sql->data[tarrif_type_end],
						"tarrif_type_duration" => $sql->data[tarrif_type_duration],
						"tarrif_type_km" => $sql->data[tarrif_type_km],
						"tarrif_type_km_total" => (($day_total * $sql->s'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_name], 
						"tarrif_type_start" => $sql->data[tarrif_type_start],
						"tarrif_type_end" => $sql->data[tarrif_type_end],
						"tarrif_type_duration" => $sql->data[tarrif_type_duration],
						"tarrif_type_km" => $sql->data[tarrif_type_km],
						"tarrif_type_km_total" => (($day_total * $sql->data[tarrif_type_km]) / $sql->data[tarrif_type_duration]),
						"tarrif_total" => (($sql->data[tarrif_value] / $sql->data[tarrif_type_duration]) * getitem(day_total)),
						"day_total" => getitem(day_total)
					   );
			}	
	}
}
?>
? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.


Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_name], 
						"tarrif_type_start" => $sql->data[tarrif_type_start],
						"tarrif_type_end" => $sql->data[tarrif_type_end],
						"tarrif_type_duration" => $sql->data[tarrif_type_duration],
						"tarrif_type_km" => $sql->data[tarrif_type_km],
						"tarrif_type_km_total" => (($day_total * $sql->data[tarrif_type_km]) / $sql->data[tarrif_type_duration]),
						"tarrif_total" => (($sql->data[tarrif_value] / $sql->data[tarrif_type_duration]) * getitem(day_total)),
						"day_total" => getitem(day_total)
					   );
			}	
	}
}
?>
SSION['var_ses'] as $Items)
{
if ($Items['name'] == $name)
{
$value = $Items['value'];
}
}
}
return $value;
}

function setitem_tarrif($category_id)
{
if(isset($category_id))
{
$sql = new MySQL_class;
$sql->Create("ajonk");
$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);

$_SESSION['tarrif'][$sql->data[tarrif_id]] =
array (
"tarrif_id" => $sql->data[tarrif_id],
"tarrif_value" => $sql->data[tarrif_value],
"tarrif_type_name" => $sql->data[tarrif_type_name],
"tarrif_type_start" => $sql->data[tarrif_type_start],
"tarrif_type_end" => $sql->data[tarrif_type_end],
"tarrif_type_duration" => $sql->data[tarrif_type_duration],
"tarrif_type_km" => $sql->data[tarrif_type_km],
"tarrif_type_km_total" => (($day_total * () function.

Here are the 2 functions i'm using.


Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;ical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

&lt;?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;data&#1111;tarrif_type_duration]) * getitem(day_totalossible to use a function within a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_name], 
						&aven practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;data&#1111;tarrif_type_duration]) * getitem(day_total)),
						&quote;day_total&quote; =&gt; getitem(day_total)
					   );
			}	
	}
}
?&a4b0da9de73]
<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_name], 
						"tarrif_type_start" => $sql->data[tarrif_type_start],
						"tarrif_type_end" => $sql->data[tarrif_type_end],
						"tarrif_type_duration" => $sql->data[tarrif_type_duration],
						"tarrif_type_km" => $sql->data[tarrif_type_km],
						"tarrif_type_km_tossible to use a function within a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_durhin a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

&lt;?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;data&#1111;tarrif_type_duration]) * getitem(day_total)),
						&quote;day_tthe function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

&lt;?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;data&#1111;tarrif_type_duration]) * getitem(day_total)),
						&quoon getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_tyossible to use a function within a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;data&#1111;tarrif_type_duration]) * getitem(day_total)),
						&quote;day_totalunction.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_em($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;data&#1111;tarrif_type_duration]) * getitem(day_total)),
						&quote;day_total&quote; =&a
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&an? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_name], 
						"tarrif_type_start" => $sql->data[tarrif_type_start],
						"tarrif_type_end" => $sql->data[tarrif_type_end],
						"tarrif_type_duration" => $sql->data[tarrif_type_duration],
						"tarrif_type_km" => $sql->data[tarrif_type_km],
						"tarrif_type_km_total" => (($day_total * $sql->data[tarrif_type_km]) / $sql->data[tarrif_type_duration]),
						"tarrif_total" => (($sql->data[tarrif_value] / $sql->data[tarrif_type_duration]) * getitem(day_total)),
						"day_total&quoteamp;lt;?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&ampn a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

&lt;?
function getitem($name)
{
	if(isset($_SESSION&#1111;'var_ses']))
	{
		foreach($_SESSION&#1111;'var_ses'] as $Items)
		{
			if ($Items&#1111;'name'] == $name)
			{
				$value = $Items&#1111;'value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql-&gt;Create(&quote;ajonk&quote;);	
		$sql-&gt;Query(&quote;SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql-&gt;data&#1111;tarrif_id]] = 
				array (
						&quote;tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&quote; =&gt; $sql-&gt;data&#1111;tarrif_value],
						&quote;tarrif_type_name&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_name], 
						&quote;tarrif_type_start&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_start],
						&quote;tarrif_type_end&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_end],
						&quote;tarrif_type_duration&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_duration],
						&quote;tarrif_type_km&quote; =&gt; $sql-&gt;data&#1111;tarrif_type_km],
						&quote;tarrif_type_km_total&quote; =&gt; (($day_total * $sql-&gt;data&#1111;tarrif_type_km]) / $sql-&gt;data&#1111;tarrif_type_duration]),
						&quote;tarrif_total&quote; =&gt; (($sql-&gt;data&#1111;tarrif_value] / $sql-&gt;data&#1111;tarrif_type_duration]) * getitem(day_total)),
		thin a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='&quote;.getitem(category_id).&quote;' ORDER BY tarrif_sort&quote;);
			for ($i = 0; $i &lt; $sql-&gt;rows; $i++)
			{
				$sql-&gt;Fetch($i);
		
				$_SESSION&#1111;'tarrif']&#1111;$sql->data[tarrif_id]] = 
				array (
						"tarrif_id&quote; =&gt; $sql-&gt;data&#1111;tarrif_id],
						&quote;tarrif_value&ampossible to use a function within a function? And is it even practical?

The idea is to use the function getitem() within setitem_tarrif() function.

Here are the 2 functions i'm using.

Code: Select all

<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_nam
<?
function getitem($name)
{
	if(isset($_SESSION['var_ses']))
	{
		foreach($_SESSION['var_ses'] as $Items)
		{
			if ($Items['name'] == $name)
			{
				$value = $Items['value'];
			}
		}
	}
	return $value;
}

function setitem_tarrif($category_id)
{
	if(isset($category_id))
	{
		$sql = new MySQL_class;
		$sql->Create("ajonk");	
		$sql->Query("SELECT * FROM tarrif,tarrif_type WHERE tarrif.tarrif_type_id=tarrif_type.tarrif_type_id AND tarrif.category_id='".getitem(category_id)."' ORDER BY tarrif_sort");
			for ($i = 0; $i < $sql->rows; $i++)
			{
				$sql->Fetch($i);
		
				$_SESSION['tarrif'][$sql->data[tarrif_id]] = 
				array (
						"tarrif_id" => $sql->data[tarrif_id],
						"tarrif_value" => $sql->data[tarrif_value],
						"tarrif_type_name" => $sql->data[tarrif_type_name], 
						"tarrif_type_start" => $sql->data[tarrif_type_start],
						"tarrif_type_end" => $sql->data[tarrif_type_end],
						"tarrif_type_duration" => $sql->data[tarrif_type_duration],
						"tarrif_type_km" => $sql->data[tarrif_type_km],
						"tarrif_type_km_total" => (($day_total * $sql->data[tarrif_type_km]) / $sql->data[tarrif_type_duration]),
						"tarrif_total" => (($sql->data[tarrif_value] / $sql->data[tarrif_type_duration]) * getitem(day_total)),
						"day_total" => getitem(day_total)
					   );
			}	
	}
}
?>

Posted: Wed Jul 06, 2005 4:42 am
by harrisonad
Yes, as long as scope is valid.
Why did you think it's impossible?

Posted: Wed Jul 06, 2005 5:58 am
by pleigh
yeah...i did something like that too...

Posted: Wed Jul 06, 2005 6:22 am
by Haller
Because getitem(day_total) has no value in the function setitem_tarrif(). And im sure it does have a value.

Do I have to redeclare it or something?

Re: Using a function within a function

Posted: Wed Jul 06, 2005 8:40 pm
by harrisonad
Haller wrote: getitem($day_total)
you forgot the $ for the day_total variable