<?php
session_start();
$bookname=$_GET['bookname'];
$groupbook=$_GET['groupbook'];
$groupbooke=$_GET['groupbooke'];
//echo $groupbooke.'ssssddddddddddd';
include("dbf.php");

if($bookname)
{
$query="SELECT * FROM `ketab` WHERE  (`name` like '%$bookname%') ";
$result=mysql_query($query);
?>
<select name="booko" tabindex="<?php echo $tab2; ?>">
<option value="">انتخاب نماييد</option>
<?php while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['id']?>><?=$row[name]." - ".$row[id]?> </option>
<?php }
echo"</select>";
}
if($groupbook)
{
	?>
		<select tabindex="2" name="sath1" id="sath1"  onchange="groupbok1(this.value,'0')"  style="font-size: 9pt;font-family:tahoma">
			<option value="" style="font-size: 9pt;font-family:tahoma">انتخاب فرمایید</option>
			<?php
			$fg15=mysql_query("select * from book_group where (sath='{$groupbook}' and city='{$_SESSION['city']}') order by ip");
			while($v15=mysql_fetch_assoc($fg15))
			{
			?>
			<option value="<?php echo $v15['ip']; ?>" style="font-size: 9pt;font-family:tahoma"><?php echo $v15['name']; ?></option>
			<?php
			}
			?>
		</select>
	<?php
}
//echo $groupbooke.'xxxxxxxxxxxx';
if(isset($_GET['groupbooke']))
{

//echo $_GET['sear'].'sssssss';
				if ($_GET['groupbooke']>0)
				{
				$fg19=mysql_query("select * from book_group where (ip='{$groupbooke}' and city='{$_SESSION['city']}') order by ip");
				$v19=mysql_fetch_assoc($fg19);
				}
						?>
						<table width="100%" align="center">
						<tr>
							<td width="20" align="right">
								<a href="textpage2.php?chooseall=1&&ketabkhas=1&&groupbook=<?php echo $_GET['groupbook']; ?>&&groupbooke=<?php echo $_GET['groupbooke']; ?> ">
								انتخاب همه
								</a>
							</td>
						</tr>
						<?php
						$color=array($_SESSION['bgcolor'],$_SESSION['bgcolor1']); $a=0;
						$kj=1;

						if ($_GET['groupbooke']>0)
						{
						$fg16=mysql_query("select *,ketab.name as kett,ketab.ip as ip,matn.ip as ip1 from ketab join `matn` where (ketab.city='{$_SESSION['city']}' and ketab.id=matn.id  and ketab.sath='{$v19['sath']}'  and ketab.sath1='{$v19['ip']}' ) order by ketab.id");
		//	echo $_GET['groupbooke'].'vvvvvvvvvvv';
						}
						elseif ($_GET['sear']!==" ")
						{
						$q="book_name";
						$qq=$_GET['sear'];
						$fg16=mysql_query("select *,ketab.name as kett,ketab.ip as ip,matn.ip as ip1 from ketab join `matn` where (ketab.city='{$_SESSION['city']}' and ketab.id=matn.id and ($q like'%$qq%')) order by ketab.id");
						}
						while($v16=mysql_fetch_assoc($fg16))
						{
						?>
						<tr  bgcolor=<?php if ($v16['choose']==1) { echo "green"; } else { echo $color[$a]; } ?>>
							<td align="right" width="33%">
								<?php
								if ($v16['choose']==1)
								{
								?>
								<a href="textpage2.php?bookipdel=<?php echo $v16['ip1']; ?>" title="انتخاب"><img src="images/b_drop.png" height="20" alt="نرم افزار کتابداری" width="20"></a>
								<?php
								}
								else
								{
								?>
								<a href="textpage2.php?bookip=<?php echo $v16['ip1']; ?>&&sath=<?php echo $v19['sath']; ?>&&sath1=<?php echo $v19['ip']; ?>" title="انتخاب"><img src="images/sabtf2.png" height="20" alt="نرم افزار کتابداری" width="20"></a>
								<?php
								}

								echo $v16['book_name'].'-'.$v16['id']; ?>
							</td>
						</tr>
						<?php
						if($a==1) $a=0;  else $a=1;
						$kj++;
						}
						?>
						</table>

						<?php
}
?>