Page 1 of 1

can anyone tell me what is this script

Posted: Mon Dec 29, 2003 7:47 am
by kujtim
can anyone tell me what is this script doing on general....

Code: Select all

<?php
$result = mysql_query("SELECT * FROM menu_main WHERE menu_lang='$HTTP_SESSION_VARS[language_id]'") or show_site_error('Error on main menu '.mysql_error());

if(mysql_num_rows($result)>0){
	
	echo"<table cellpadding=2 cellspacing=0 border=0   class=menuMainTable><tr>";
	
	$i=0;
	while ($row = mysql_fetch_array($result)) {

	$link 	= $PHP_SELF."?menu_id=".$row['menu_id'];

	/* selects clicked menu */
	if ($HTTP_SESSION_VARS[menu_id] == $row['menu_id'])
		$class="menuMainLinkCurrent & menuMainTdCurrent";
	
	/* selects first link in main menu if language is changed */
	else if($HTTP_GET_VARS[language_id] && $i==0){
		$HTTP_SESSION_VARS[menu_id]	 = $row['menu_id'];
		$class="menuMainLinkCurrent & menuMainTdCurrent";
	}
	else
		$class="menuMainLink";
	

	echo"<td  align=center valign=middle class='$class' nowrap >
			<a href='$link' title="".text_from_sql($row[menu_desc])."">
				<span class='$class'> ".text_from_sql($row[menu_name])." </span>
			</a></td>";
	echo"<td class=menuMainLink width=1>|</td>";
	
	$i++;
	}
	
		echo"<td width=100%>&nbsp;</td>";
		echo"</tr></table>";
}
?>

Re: can anyone tell me what is this script

Posted: Mon Dec 29, 2003 8:05 am
by Derfel Cadarn
kujtim wrote:can anyone tell me what is this script doing on general....
Well, in GENERAL: not much, since it uses deprecated variable-names like $HTTP_SESSION_VARS[language_id], you should use $_SESSION[] instead.

The goal of the script you gave was:
1. read all data from a MySQL-table 'menu_main';
2. show all data in a HTML-table, with the data from the row 'menu-name' are shown as a link (referring to the data in row 'menu_desc'. The rest is shown using different kinds of mark-up (CSS-Classes are used).

Is that enough? :lol:

$HTTP_SESSION_VARS

Posted: Mon Dec 29, 2003 8:27 am
by kujtim
halo
i am a new in php and i dont now why is this script:$HTTP_SESSION_VARS wroted what is this script doing ......


please ...

Posted: Mon Dec 29, 2003 8:32 am
by Derfel Cadarn
I'm sorry, but I don't understand your last question. Have you read the manual at php.net and especially about reserved variables?