Эта тема на forum.dklab.ru


Ayaz2008: Фильтрафия в поиске по формату файлов.
вот смотрите, это скрипт поиска.

здесь надо сделать вот что...
3 параметра по поиску, 4ыйй надо добавить... фильтрация по расширенирению файлов в папке libarary. Т.е. какие форматы файлов есть, их показать в следущем комбобоксе + фильтрация...

<HTML>
<HEAD>
<TITLE>agro-imm.az</TITLE>
<meta http-equiv="Content-Type" content="text/css; charset=utf-8" />
<LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<TABLE WIDTH=725 BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
<TR>
<TD WIDTH=725 HEIGHT=216 ALT="" valign="top">
<div style="z-index:-1 "><TABLE WIDTH=725 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD><IMG SRC="images/top2.jpg" WIDTH=10 HEIGHT=77 ALT=""></TD>
<TD><IMG SRC="images/logo.jpg" WIDTH=235 HEIGHT=77 ALT=""></TD>
<TD WIDTH=472 HEIGHT=77 ALT="" valign="top" background="images/top_px.gif">
<TABLE WIDTH=472 BORDER=0 CELLPADDING=0 CELLSPACING=0 background="images/px1.gif">
<TR>
<TD><a href="http://www.agro-imm.az/index.php?id=5"><IMG SRC="images/m1.jpg" ALT="" WIDTH=95 HEIGHT=77 border="0"></a></TD>
<TD><IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=77 ALT=""></TD>
<TD><a href="http://www.agro-imm.az/library/"><IMG SRC="images/m2.jpg" ALT="" WIDTH=93 HEIGHT=77 border="0"></a></TD>
<TD><IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=77 ALT=""></TD>
<TD><a href="http://www.agro-imm.az/index.php?id=7"><IMG SRC="images/m3.jpg" ALT="" WIDTH=93 HEIGHT=77 border="0"></a></TD>
<TD background="images/px3.gif"><IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=77 ALT=""></TD>
<TD><a href="http://www.agro-imm.az/forum2/"><IMG SRC="images/m4.jpg" ALT="" WIDTH=93 HEIGHT=77 border="0"></a></TD>
<TD background="images/px2.gif"><IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=77 ALT=""></TD>
<TD><a href="http://www.agro-imm.az/index.php?id=8"><IMG SRC="images/m5.jpg" ALT="" WIDTH=94 HEIGHT=77 border="0"></a></TD>
</TR>
</TABLE> </TD>
<TD><IMG SRC="images/top1.jpg" WIDTH=8 HEIGHT=77 ALT=""></TD></TR>
<TR><TD COLSPAN=4><IMG SRC="images/top_im.jpg" WIDTH=725 HEIGHT=139 ALT=""></TD></TR>
</TABLE></div> </TD>
</TR>
<TR><TD><IMG SRC="images/spacer.gif" WIDTH=725 HEIGHT=2 ALT=""></TD></TR>
<TR>
<TD WIDTH=725 HEIGHT=410 ALT="" valign="top" bgcolor="#317635" style="padding-top:22px; padding-bottom:20px "> <div style="margin-left:28px; width:675px " class="white">
<img src="images/3txt1.gif"><br>
<br>
<?php
include_once 'config.php';
mysql_connect(DB_HOST,DB_USER,DB_PASS);
mysql_select_db(DB_NAME);
mysql_query('SET NAMES UTF8;');
?>
<form id="form1" name="form1" method="post" action="search.php">
<label> <u>Расширенный поиск:</u><br />
<br />
<input type="text" name="query" id="textfield" />
<select name="title" id="select">
<option>Название</option>
<?php
$result = mysql_query('SELECT DISTINCT(`book_title`) FROM `tbl_books`;');
while($row=mysql_fetch_row($result))
echo ' <option value="'.htmlspecialchars($row[0]).'">'.$row[0].'</option>';
mysql_free_result($result);
?>
</select>
</label>
<label>
<select name="author" id="select2">
<option>Автор</option>
<?php
$result = mysql_query('SELECT DISTINCT(`book_author`) FROM `tbl_books`;');
while($row=mysql_fetch_row($result))
echo ' <option value="'.htmlspecialchars($row[0]).'">'.$row[0].'</option>';
mysql_free_result($result);
?>
</select>
</label>
<label>
<select name="year" id="select3">
<option>Год</option>
<?php
$result = mysql_query('SELECT DISTINCT(`book_year`) FROM `tbl_books`;');
while($row=mysql_fetch_row($result))
echo ' <option value="'.htmlspecialchars($row[0]).'">'.$row[0].'</option>';
mysql_free_result($result);
?>
</select>
</label>
<p>
<label>
<input type="submit" name="button" id="button" value="Искать" />
</label>
</p>
</form>
<?php
$result = null;
if (isset($_POST['title']) && isset($_POST['author']) && isset($_POST['year']) and
($_POST['title']!='Название' || $_POST['author']!='Автор' || $_POST['year']!='Год')
)
{ $_POST['title'] = mysql_real_escape_string($_POST['title']);
$_POST['author'] = mysql_real_escape_string($_POST['author']);
$_POST['year'] = mysql_real_escape_string($_POST['year']);
$result = mysql_query('SELECT `book_title`, `book_author`, `book_year`, `book_file` FROM `tbl_books` WHERE `book_title` = \''.$_POST['title'].'\' OR `book_author` = \''.$_POST['author'].'\' OR `book_year` = \''.$_POST['year'].'\'');
if ($result != null)
{ echo 'Результаты поиска:';
echo '<ul>';
while($row = mysql_fetch_row($result))
{ $filename='library/'.$row[3];
echo '<li><a href="'.$filename.'">'.$row[0]. ' ' . $row[1] . ' ' . $row[2] .'</a></li>';
if ( isset ($_POST['query']) && $_POST['query'] != '')
{ $text=html_to_utf8(strip_tags(file_get_contents($filename)));
if ($text!="")
{ $allWords=true;
$words=explode(' ', $_POST["query"]);
$lastpos=0;
$curRes="";
$k=0;
foreach ($words as $word)
{ $k++;
$pos=strpos($text, $word);
if ($pos===false) { $allWords=false; }
else
{ $leftpos=$pos-100;
if ($leftpos<0) $leftpos=0;
$leftpos=strpos($text, ' ', $leftpos);
if ($leftpos>$pos) $leftpos=$pos;
if ($lastpos>$leftpos)
{ if ($lastpos>$pos)
{ $curRes=str_replace($word, "<B>".$word."</B>", $curRes); $pos=$lastpos; }
}
$leftpos=$lastpos;
}
$rightpos=$leftpos+400;
if ($rightpos>=strlen($text)) { $rightpos=strlen($text); }
else { $rightpos=strpos($text, ' ', $rightpos); }
if ($leftpos>$lastpos&&$lastpos>0) $curRes.=" ... ";
if ($allWords){
print '<small>(.. '.str_replace($word, "<B>".$word."</B>",substr($text, $leftpos, $rightpos-$leftpos)).' ..)</small>';}
$lastpos=$rightpos;
}
}
}
}
echo '</ul>';
mysql_free_result($result);
}
}
elseif ( isset($_POST['query']) && $_POST['query']!='')

{ $dh=opendir('library');
print '<ul>';
while (gettype ($filename=readdir($dh))!=boolean)
{ $text=html_to_utf8(strip_tags(file_get_contents('library/'.$filename)));
if ($text!="")
{ $allWords=true;
$words=explode(' ', $_POST["query"]);
$lastpos=0;
$curRes="";
$k=0;
foreach ($words as $word){ if ($word!='')
{ $k++;
$pos=strpos($text, $word);
if ($pos===false) { $allWords=false; }
else
{ $leftpos=$pos-100;
if ($leftpos<0) $leftpos=0;
$leftpos=strpos($text, ' ', $leftpos);
if ($leftpos>$pos) $leftpos=$pos;
if ($lastpos>$leftpos)
{ if ($lastpos>$pos)
{ $curRes=str_replace($word, "<B>".$word."</B>", $curRes); $pos=$lastpos; }
}
$leftpos=$lastpos;
}
$rightpos=$leftpos+400;
if ($rightpos>=strlen($text)) { $rightpos=strlen($text); }
else { $rightpos=strpos($text, ' ', $rightpos); }
if ($leftpos>$lastpos&&$lastpos>0) $curRes.=" ... ";
if ($allWords) {
print '<li><a href="library/'.$filename.'">'.$filename.'</a></li>';
print '<small>(.. '.str_replace($word, "<B>".$word."</B>",substr($text, $leftpos, $rightpos-$leftpos)).' ..)</small>';}
$lastpos=$rightpos;
}}
}
}
print '</ul>';
closedir ($dh);
}

function html_to_utf8 ($data)
{ return preg_replace("/\\&\\#([0-9]{3,10})\\;/e", '_html_to_utf8("\\1")', $data); }

function _html_to_utf8 ($data)
{ if ($data > 127)
{ $i = 5;
while (($i--) > 0)
{ if ($data != ($a = $data % ($p = pow(64, $i))))
{ $ret = chr(base_convert(str_pad(str_repeat(1, $i + 1), 8, "0"), 2, 10) + (($data - $a) / $p));
for ($i; $i > 0; $i--)
$ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
break;
}
}
}
else
$ret = "&#$data;";
return $ret;
}


?>
<?php
mysql_close();
?>

</div> </TD>
</TR>
<TR>
<TD WIDTH=725 HEIGHT=47 ALT="" valign="top" background="images/bot_px.gif">
<table width="725" height="47" border="0" cellspacing="0" cellpadding="0">
<tr>
<TD
style="BACKGROUND-POSITION: 50% bottom; BACKGROUND-REPEAT: no-repeat"
width=5 background=images/bot_corn_left.gif><IMG
height=1 src="images/spacer.gif" width=5></TD>
<TD style="PADDING-TOP: 12px" vAlign=top width=715>
<DIV class=bot_txt align=center><STRONG><A class="bot_txt u" id=a
href="index.php">Ana s&#601;hif&#601;</A><IMG height=1
src="images/spacer.gif" width=20>:<IMG height=1
src="images/spacer.gif" width=20><A class="bot_txt u" id=a
href="index.php?id=5">Umumi malumat</A><IMG height=1
src="images/spacer.gif" width=20>:<IMG height=1
src="images/spacer.gif" width=20><A class="bot_txt u"
id=a href="index.php?id=6">Kitabxana</A><IMG
height=1 src="images/spacer.gif" width=20>:<IMG
height=1 src="images/spacer.gif" width=20><A
class="bot_txt u" id=a href="index.php?id=7">RMM-l&#601;r</A><IMG
height=1 src="images/spacer.gif" width=20>:<IMG
height=1 src="images/spacer.gif" width=20><A
class="bot_txt u" id=a href="/forum2/">Forum</A><IMG
height=1 src="images/spacer.gif" width=20>:<IMG
height=1 src="images/spacer.gif" width=20><A
class="bot_txt u" id=a
href="index.php?id=8">FAQ</A><IMG
height=1 src="images/spacer.gif" width=20>:<IMG
height=1 src="images/spacer.gif" width=20><A
class="bot_txt u" id=a href="index.php?id=9">English version</A></STRONG></DIV>
<IMG height=5
src="images/spacer.gif" width=1><BR>
<DIV class=copy align=center><A class=copy
>Copyright 2008. Bütün
hüquqlar qorunub.</A></DIV></TD>
</tr>
</table> </TD>
</TR>
</TABLE>
</BODY>
</HTML>
dimagolov:
Если это ТЗ, то где предлагаемая оплата?

Эта тема на forum.dklab.ru