Вот неплохая менюшка (для роботы нужна база данных)
Цитата:
<?php
if(isset($_GET["page"]))
{
$clickpage=$_GET["page"];
$result=$mysql->query("SELECT * FROM `top_menu` WHERE `page`='$clickpage'");
$link=$mysql->get($result,"link");
$mysql->query("SELECT *FROM `top_menu` WHERE `def` = 'alpha'");
}
else
{
$result=$mysql->query("SELECT * FROM `top_menu` WHERE `def`='1'");
if(mysql_num_rows($result))
{
$clickpage=$mysql->get($result,"page");
}
else
{
/*$result=$mysql->query("SELECT * FROM `top_menu` ORDER BY `menuid`");
$clickpage=$mysql->get($result,"page");*/
}
$result=$mysql->query("SELECT * FROM `top_menu` WHERE `page`='$clickpage'");
$link=$mysql->get($result,"link");
}
$description=$mysql->get($result,"description");
echo '
<table width="100%" height="23" border="0" cellpadding="0" cellspacing="0" style="background:#FFFFFF">
<tr>
<td width="25" nowrap class="menu_bor_bot" valign="bottom"><img src="../index/leshost/menu_right_bg.gif" /></td>
';
$result=$mysql->query("SELECT * FROM `top_menu` ORDER BY `menuid`");
if(mysql_num_rows($result))
{
$menuItemCount=mysql_num_rows($result);
if($clickpage!=$mysql->get($result,"page"))
{
echo '
<td nowrap class="menu_sep"> </td>
';
}
for($i=0;$i<$menuItemCount;$i++)
{
if($mysql->get($result,"page",$i)==$clickpage)
{
echo '
<td nowrap class="menu_sel_begin"> </td>
<td nowrap class="menu_sel_center">'.$mysql->get($result,"caption",$i).'</td>
<td nowrap class="menu_sel_end"> </td>
';
}
else
{
if($mysql->get($result,"newwindow",$i))
{
$target=' target="_blank"';
}
else
{
$target='';
}
if($mysql->get($result,"onlyinner",$i))
{
$href=$mysql->get($result,"link",$i);
}
else
{
$href='index.php?page='.$mysql->get($result,"page",$i).'&lang='.$lang.'';
}
echo '
<td nowrap class="menu_off_center"><a style="color:#000000;" href="'.$href.'"'.$target.'>'.$mysql->get($result,"caption",$i).'</a></td>
';
if($mysql->get($result,"page",$i+1)!=$clickpage)
{
echo '
<td nowrap class="menu_sep"> </td>
';
}
}
}
}
else
{
echo '<td nowrap class="menu_bor_bot">No menu</td>';
}
echo'<td width="100%" class="menu_bor_bot" align="right" valign="middle">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="right" valign="middle"></td>
</tr>
</table>
</td>
<td width="100%" class="menu_bor_bot" align="right"><img src="../index/leshost/menu_left_bg.gif" /></td>
</tr>
</table>
';
?>
А вот собственно таблица с которой работает скрипт:
Цитата:
CREATE TABLE `top_menu` (
`menuid` int(10) NOT NULL default '0',
`newsid` int(10) NOT NULL default '0',
`page` varchar(50) NOT NULL,
`caption` varchar(50) NOT NULL default 'noname',
`description` varchar(100) NOT NULL default ' ',
`newwindow` tinyint(1) NOT NULL default '0',
`def` tinyint(1) NOT NULL default '0',
`onlyinner` tinyint(1) NOT NULL default '0',
`link` varchar(200) NOT NULL default 'about:blank'
) ENGINE=MyISAM DEFAULT CHARSET=utf8
Добавлено: Вот неплохая функция для создания thumb-ов
Код: function make_thumb($fold, $file, $trumb_size_y)
{
$jpg_quality = 100;
echo $fold.$file;
if(file_exists($fold.$file))
{
$size = getimagesize($fold.$file);
$b=imagecreatefromjpeg($fold.$file);
$t=imagecreatetruecolor(($trumb_size_y)*($size[0]/$size[1]),$trumb_size_y);
imagecopyresized($t,$b,0,0,0,0,($trumb_size_y)*($size[0]/$size[1]),$trumb_size_y,$size[0],$size[1]);
if(eregi(".jpg$|.jpeg$",$file)) imagejpeg($t,$fold."thumb/".$file,$jpg_quality);
if(eregi(".gif$",$file)) imagegif($t,$fold."thumb/".$file);
if(eregi(".png$",$file)) imagepng($t,$fold."thumb/".$file);
$trumb_size_y = 300;
$t=imagecreatetruecolor(($trumb_size_y)*($size[0]/$size[1]),$trumb_size_y);
imagecopyresized($t,$b,0,0,0,0,($trumb_size_y)*($size[0]/$size[1]),$trumb_size_y,$size[0],$size[1]);
if(eregi(".jpg$|.jpeg$",$file)) imagejpeg($t,$fold."zoom/".$file,$jpg_quality);
if(eregi(".gif$",$file)) imagegif($t,$fold."zoom/".$file);
if(eregi(".png$",$file)) imagepng($t,$fold."zoom/".$file);
}
}