memeri
Member
مشکل این کدچیه که سرچ با این که هست ولی نتیجه ای رو در بر نداره و فقط قسمت orginal نتیجه میده اونم فکر کنم چون انگلیسی

function
search.php
PHP:
<?php
/*
function for search in the news at mersa.ir
version 2
*/
function displaysearch($body,$firtsub,$subject,$orginal){
?>
<form method="POST" action="search.php">
<fieldset style="padding: 2">
<legend>جستجو میان اخبار</legend>
<p align="right">
<input type="text" name="subject" size="30" dir="rtl" value="<?php echo ($subject); ?>"><span lang="en-us">
</span>موضوع<span lang="en-us"> </span>
<p align="right">
<input type="text" name="orginal" size="30" value="<?php echo ($orginal); ?>" dir="rtl"><span lang="en-us">
</span>منبع<span lang="en-us"> </span></p>
<p align="right">
<select size="1" name="firtsub" dir="rtl" style="font-family: Times New Roman">
<option selected value="all">همه</option>
<option value="siyasi">سیاسی</option>
<option value="sport">ورزشی</option>
<option value="elmi">علمی</option>
<option value="eghtesadi">اقتصادی</option>
<option value="farhangi">فرهنگی</option>
</select><span lang="en-us">
</span>دسته</p>
<p align="right"><textarea rows="3" name="body" cols="25" dir="rtl"><?php echo ($body); ?></textarea><span lang="en-us">
</span>متن</p>
<p align="center">
<input type="image" src="Image/search.gif"right" name="search" width="48" height="48"> </p>
</form>
<?php
}
##########################################end displaysearch function
##########################################new function
function showsearch($page=0,$subject,$firtsub,$orginal,$body){
global $conn;
$sql = "select * from news";
if ($body != ''){
if ($ok == 1){
$sql = $sql.' '."and body = '$body'";
} else {
$sql = $sql.' '."where body = '$body'";
$ok = '1';
}
}
if ($firtsub != 'all'){
if ($ok == 1){
$sql = $sql.' '."and firtsub = '$firtsub'";
} else {
$sql = $sql.' '."where firtsub = '$firtsub'";
$ok = '1';
}
}
if ($orginal != ''){
if ($ok == ''){
$sql = $sql.' '."where orginal regexp '$orginal'";
$ok = '1';
} else {
$sql = $sql.' '."and orginal regexp '$orginal'";
}
}
if ($subject != ''){
if ($ok == ''){
$sql = $sql.' '."where subject regexp '$subject'";
$ok = '1';
} else {
$sql = $sql.' '."and subject regexp '$subject'";
}
}
$res = mysql_query($sql,$conn);
$allnum=mysql_num_rows($res);
if ($page == '' or $page == 1 or $page == 0){
$sql = $sql.' '.'ORDER BY id DESC limit 0,10';
$back='off';
if ($allnum > 10){
$next='on';
} else {
$next='off';
}
} else {
$start=$page-1;
$start=$start*10;
$sql=$sql." limit $start,10";
if ($allnum > $start+10){
$next='on';
} else {
$next='off';
}
$back='on';
}
$res = mysql_query($sql,$conn);
$num=mysql_num_rows($res);
print "<p align=\"right\">";
print "صفحه ";
print "$page";
print "از";
$baghi = $allnum % 10;
$a1=$allnum - $baghi;
$a2=$a1/10;
$a2 = $a2+1;
print ($a2);
print "</p>";
if ($num == 0){
print "<p align=\"right\">";
print "جستجو نتیجه ای دربر نداشت";
print "<br>";
displaysearch ($body,$firtsub,$subject,$orginal);
?>
</td>
<td width="165" valign="top">
<?php
include '../right.php';
?>
</td>
</tr>
</table>
</div>
<p>
</td>
</tr>
</table>
</div>
</body>
</html>
<?php
print "</p>";
exit;
}
for ($i=0;$i<$num;$i++){
$row=mysql_fetch_array($res);
?><p align="right">
<table cellpadding="0" cellspacing="0" width="400">
<!-- MSTableType="layout" -->
<tr>
<td valign="top" background="Image/title2.gif" align="right">
<b> <a href="news.php?id=<?php echo ($row['id']); ?>">
<span lang="fa">دسته</span></b>
<span lang="fa">:
<?php
switch ($row['firtsub']){
case 'siyasi':
$select = 'سیاسی';
break;
#####################################
case 'sport':
$select = 'ورزشی';
break;
####################################
case 'elimi':
$select = 'علمی';
break;
####################################
case 'eghtesadi':
$select = 'اقتصادی';
break;
####################################
case 'farhangi':
$select = 'فرهنگی';
break;
}
print ($select);
?>
<b>منبع</b>:
<?php
print ($row['orginal']);
?><br>
<?php
print ($row['subject']);
?></a>
</span> </td>
</tr>
<tr>
<td>
<p align="right"><br>
<?php
print ($row['body']);
?></p> <p align="center">
<?php
print ($row['DATA']);;
?>
</p>
</td>
</tr>
</table></p>
<?php
}
?>
<br>
<table cellpadding="0" cellspacing="0" width="420">
<!-- MSTableType="layout" -->
<tr>
<td width="186" align="left">
<?php
if ($next == 'ok'){
?><p align="center">
<form method="post" action="search.php">
<input type="hidden" name="page" value="<?php print ($page+1); ?>">
<input type="hidden" name="body" value="<?php print ($body); ?>">
<input type="hidden" name="orginal" value="<?php print ($orginal); ?>">
<input type="hidden" name="subject" value="<?php print ($subject); ?>">
<input type="hidden" name="firtsub" value="<?php print ($firtsub); ?>">
<p align="center">
<input type="image" src="Image/Fa-btn-next.jpg">
</p>
</form></p>
<?php
}
?>
</td>
<td>
<?php
if ($back == 'on'){
?><p align="center">
<form method="post" action="search.php">
<input type="hidden" name="page" value="<?php print ($page-1); ?>">
<input type="hidden" name="body" value="<?php print ($body); ?>">
<input type="hidden" name="orginal" value="<?php print ($orginal); ?>">
<input type="hidden" name="subject" value="<?php print ($subject); ?>">
<input type="hidden" name="firtsub" value="<?php print ($firtsub); ?>">
<p align="center">
<input type="image" src="Image/Fa-btn-prior.jpg">
</p>
</form></p>
<?php
}
?>
</td></tr></table>
<?php
}
?>
search.php
PHP:
<?php
include '../session.php';
include '../config.php';
$orginal2 = $_POST['orginal'];
$page2 = $_POST['page'];
$subject2 = $_POST['subject'];
$body2 = $_POST['body'];
$firtsub2 = $_POST['firtsub'];
$ok = '';
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>Mersa.Ir</title>
</head>
<body>
<div align="center">
<table cellpadding="0" cellspacing="0" width="800" height="19">
<!-- MSTableType="layout" -->
<tr>
<td width="800" valign="top" height="19">
<?php
include '../header_es.php';
?>
</td>
</tr>
<tr>
<td width="800" valign="top" height="10">
<div align="center">
<table cellpadding="0" cellspacing="0" width="766">
<!-- MSTableType="layout" -->
<tr>
<td valign="top" width="165">
<?php
include '../left.php';
?>
</td>
<td width="420" valign="top">
<?php
include 'function.php';
$orginal=$_POST['orginal'];
$subject=$_POST['subject'];
$firtsub=$_POST['firtsub'];
$page=$_POST['page'];
$body=$_POST['body'];
if ($body != '' or $firtsub != '' or $body != '' or !orginal != ''){
showsearch ($page,$subject,$firtsub,$orginal,$body);
} else {
displaysearch ($body,$firtsub,$subject,$orginal);
}
?>
</td>
<td width="165" valign="top">
<?php
include '../right.php';
?>
</td>
</tr>
</td>
</tr>
</table>
</div>
</body>
</html>