<?php

$active_page = !empty($_GET['page']) ? $_GET['page'] : 0;

if ($_GET['action']  == "search")
				{
					$abfrage = "SELECT COUNT(itemname) FROM global_item WHERE itemname LIKE '%".$_POST['searchitem']."%'";
					$result = mysql_query($abfrage);
				} else {
					$result=mysql_query('SELECT COUNT(itemid) FROM global_item');
				}
			list($entries)=mysql_fetch_row($result);

			$blaettern=new blaettern($active_page, $entries);


?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	        <tr>
	          <td class="sitemenu"><strong>Item Database</strong></td>
	          </tr>
	        <tr>
	          <td class="sitemenu"><hr size="1" /></td>
	          </tr>
	        <tr>
	          <td align="left" valign="top" class="sitemenu"><table width="100%" border="0" cellspacing="0" cellpadding="0">
	            <tr>
	              <td colspan="2" align="left" valign="top" class="sitemenu">Items in Database: <?php echo $entries; ?></td>
	              <td colspan="2" align="right" valign="top" class="sitemenu"><form id="form1" name="form1" method="post" action="index.php?show=menu_main&content=itemdb&action=search">
	                <input name="searchitem" type="text" id="searchitem" size="20" maxlength="25" /> 
	                <input type="submit" name="button" id="button" value="search" />
	                </form></td>
	              </tr>
	            <tr>
	              <td colspan="4" align="left" valign="top" class="sitemenu"><hr size="1" /></td>
	              </tr>
	            <tr>
	              <td colspan="4" align="center" valign="top" class="sitemenu">
<?php


$blaettern->setLinkHref('index.php?show=menu_main&content=itemdb&amp;page=');
$blaettern->setDelimiter1(' ');
$blaettern->setDelimiter3(', ');
$blaettern->setLinkActiveMore(' style="font-size:13px;"');
$blaettern->setLinkFirstLastText('Machst Du Seite 1', 'Machst Du Seite ganz hinten');
$blaettern->setShowActiveLink('false');
$blaettern->setShowFirstLast(false);
$blaettern->setShowNextPrev(false);

if ($_GET['action']  == "search")
				{
					$blaettern->setEntriesPerPage(400);
				} else {
					$blaettern->setEntriesPerPage(150);
				}
echo $blaettern->create(); 

?>				</td>
	              </tr>
	            <tr>
	              <td colspan="4" align="left" valign="top" class="sitemenu"><hr size="1" /></td>
	              </tr>
				  <tr>
	              <td width="10%" align="left" valign="top" bgcolor="#333333" class="sitemenu">Item ID</td>
	              <td width="40%" align="left" valign="top" bgcolor="#333333" class="sitemenu">Summon</td>
	              <td width="43%" align="left" valign="top" bgcolor="#333333" class="sitemenu">Description</td>
	              <td width="7%" align="right" valign="top" bgcolor="#333333" class="sitemenu">Level</td>
	              </tr>
<?php
					$bg = "";
						if ($_GET['action']  == "search")
							{
								$abfrage = "SELECT * FROM global_item WHERE itemname LIKE '%".$_POST['searchitem']."%' ORDER by level ASC";
								$ergebnis = mysql_query($abfrage);
									while($row = mysql_fetch_array($ergebnis))
										{
											if ($bg== "") { $bg = "#4F4F4F"; } else { $bg = ""; }
								echo "	<tr>
											<td width='10%' align='left' valign='top' bgcolor='".$bg."' class='sitemenu'>".$row['itemid']."</td>
											<td width='40%' align='left' valign='top' bgcolor='".$bg."' class='sitemenu'>".$row['summon']."</td>
											<td width='43%' align='left' valign='top' bgcolor='".$bg."' class='sitemenu'>".$row['itemname']."</td>
											<td width='7%' align='right' valign='top' bgcolor='".$bg."' class='sitemenu'>".$row['level']."</td>
										</tr>";
										}
						
							} else {
								$result=mysql_query('SELECT * FROM global_item ORDER by level ASC LIMIT '.($blaettern->getEntriesPerPage() * $blaettern->getActivePage()).', '.$blaettern->getEntriesPerPage());
									while ($row = mysql_fetch_array($result)) 
										{
											if ($bg== "") { $bg = "#4F4F4F"; } else { $bg = ""; }
											
								echo "	<tr>
											<td width='10%' align='left' valign='top' bgcolor='".$bg."' class='sitemenu'>".$row['itemid']."</td>
											<td width='40%' align='left' valign='top' bgcolor='".$bg."' class='sitemenu'>".$row['summon']."</td>
											<td width='43%' align='left' valign='top' bgcolor='".$bg."' class='sitemenu'>".$row['itemname']."</td>
											<td width='7%' align='right' valign='top' bgcolor='".$bg."' class='sitemenu'>".$row['level']."</td>
										</tr>";
										}
							}
?>
	            
	            </table></td>
	          </tr>
          </table>