Napisałem własną wyszukiwarkę. I podzieliłem na wyszukiwanie proste, zaawansowane itp.
Tutaj kod zaawansowanego:
<?php
case 'advanced'<span style="color: #007700": {
if ($_POST['City'] != "") {$City = "= '".$_POST['City']."'";} else {$City = "LIKE '%%'";}
if ($_POST['AgeMin'] != "-") {$AgeMin = SubtractionTime
(date("Y-m-d"),substr($_POST['AgeMin'],0
,2
));} else {$AgeMin = '2099-12-31';} if ($_POST['AgeMax'] != "-") {$AgeMax = SubtractionTime
(date("Y-m-d"),substr($_POST['AgeMax'],0
,2
));} else {$AgeMax = '0000-00-00';} if ($_POST['Sex'] == "men") {$Sex = "='M'";} elseif ($_POST['Sex'] == "women") {$Sex = "='F'";} else {$Sex = "LIKE '%%'";}
if ($_POST['Sort'] == "ostatnia aktywność") { $Sort = 'UserLastActive'; } elseif ($_POST['Sort'] == "najnowsze zdjęcie") {$Sort = 'UserLastPhoto';} elseif ($_POST['Sort'] == "po średniej") {$Sort = 'UserAverageMark';} elseif ($_POST['Sort'] == "alfabetycznie") {$Sort = 'UserNick';}
if ($_POST['MinHeight'] != "-") { $MinHeight = substr($_POST['MinHeight'],0
,3
);} else {$MinHeight = 0;} if ($_POST['MaxHeight'] != "-") { $MaxHeight = substr($_POST['MaxHeight'],0
,3
);} else {$MaxHeight = 230;} if ($_POST['HairColor'] != "dowolny") {$HairColor = "= '".$_POST['HairColor']."'";} else {$HairColor = "LIKE '%%'";}
if ($_POST['HairLength'] != "dowolna") {$HairLength = "= '".$_POST['HairLength']."'";} else {$HairLength = "LIKE '%%'";}
if ($_POST['EyesColor'] != "dowolny") {$EyesColor = "= '".$_POST['EyesColor']."'";} else {$EyesColor = "LIKE '%%'";}
if ($_POST['Smoke'] != "dowolnie") {$Smoke = "= '".$_POST['Smoke']."'";} else {$Smoke = "LIKE '%%'";}
if ($_POST['Alcohol'] != "dowolnie") {$Alcohol = "= '".$_POST['Alcohol']."'";} else {$Alcohol = "LIKE '%%'";}
if ($_POST['Education'] != "dowolne") {$Education = "= '".$_POST['Education']."'";} else {$Education = "LIKE '%%'";}
if ($_POST['Children'] != "dowolnie") {$Children = "= '".$_POST['Children']."'";} else {$Children = "LIKE '%%'";}
if ($_POST['GG'] != "GG") {$GG = "LIKE '%%'";} else {$GG = "!= '' AND UserHideGG = 'No'"; }
if ($_POST['Skype'] != "Skype") {$Skype = "LIKE '%%'";} else {$Skype = "!= '' AND UserHideSkype = 'No'"; }
$DB = new Engine( DBHOST, DBADMIN, DBPASS, DBNAME );
if ( $DB->IsConnected ) {
$DB->Query("SELECT FROM Users WHERE UserGG ".$GG." AND UserSkype ".$Skype." AND UserLocCity ".$City." AND UserBirthDate BETWEEN '$AgeMax' AND '$AgeMin' AND UserSex ".$Sex." AND UserHairColor ".$HairColor." AND UserHairLength ".$HairLength." AND UserEyesColor ".$EyesColor." AND UserSmoke ".$Smoke." AND UserAlcohol ".$Alcohol." AND UserEducation ".$Education." AND UserChildren ".$Children." AND UserHeight BETWEEN '$MinHeight' AND '$MaxHeight' ORDER BY ".$Sort.";");
$Records = $DB->NRows();
$Photos = 10;
if ($Records == 1) {
while ($Row = $DB->FetchArray()) { HREF("profile.php?id=".$Row['UserID']); }
} elseif($Records > 1) {
if ( !isset($_GET['subpage']) ) { $_GET['subpage'] = 1;
}
$subpages = ceil($Records/$Photos);
$Start = ($_GET['subpage']-1)*$Photos;
$Temp = 0;
echo '<div align="center" width="80%"><table><tr>';
if($_GET['subpage']>1
) echo '<td><a href="search.php?method=advanced&subpage='.($_GET['subpage']-1).'">Poprzednia</a></td>'; if($subpages<=10)
{
for ($s=1; $s<=$subpages; $s++){
if ($s==$_GET['subpage']) echo '<td>'.$s.'</td>'; else echo '<td><a href="search.php?method=advanced&subpage='.$s.'">'.$s.'</a></td>';} }
elseif($subpages>10)
{
if($next>=6 && $_GET['$subpage']<=$subpages-5){
$wr=$_GET['subpage']-4;
$wz=$_GET['subpage']+5;
for ($s=$wr; $s<=$wz; $s++){
if ($s==$_GET['subpage']) echo '<td>'.$s.'</td>'; else echo '<td><a href="search.php?method=advanced&subpage='.$s.'">'.$s.'</a></td>'; }
}
else if($_GET['subpage']>=$subpages-5){
for ($s=$subpages-9; $s<=$subpages; $s++){
if ($s==$_GET['subpage']) echo '<td>'.$s.'</td>'; else echo '<td><a href="search.php?method=advanced&subpage='.$s.'">'.$s.'</a></td>'; }
}
else{
for ($s=1; $s<=10; $s++){
if ($s==$_GET['subpage']) echo '<td>'.$s.'</td>'; else echo '<td><a href="search.php?method=advanced&subpage='.$s.'">'.$s.'</a></td>';} }
} if($_GET['subpage']<$subpages) echo '<td><a href="search.php?method=advanced&subpage='.($_GET['subpage']+1).'">Następna</a></td>'; echo "</tr></table></div>";
$DB->Query("SELECT * FROM Users WHERE UserGG ".$GG." AND UserSkype ".$Skype." AND UserLocCity ".$City." AND UserBirthDate BETWEEN '$AgeMax' AND '$AgeMin' AND UserSex ".$Sex." AND UserHairColor ".$HairColor." AND UserHairLength ".$HairLength." AND UserEyesColor ".$EyesColor." AND UserSmoke ".$Smoke." AND UserAlcohol ".$Alcohol." AND UserEducation ".$Education." AND UserChildren ".$Children." AND UserHeight BETWEEN '$MinHeight' AND '$MaxHeight' ORDER BY ".$Sort." LIMIT $Start,$Photos;");
echo '<div align="center" width="80%" style="overflo:hidden;border: 2px #f49410 solid;"><br />';
while ( $Row = $DB->FetchArray() ) {
if ($Row['UserHideEmail'] == "Yes") { $Row['UserEmail'] = 'Ukryty'; }
if ($Row['UserHideGG'] == "Yes") { $Row['UserGG'] = 'Ukryty'; }
if ($Row['UserHideSkype'] == "Yes") { $Row['UserSkype'] = 'Ukryty'; }
$Temp++;
echo '<div style="alig:center;overflo:hidden;border: 1px #ff7400 dashed;floa:left;widt:202px;"> <div width="200"><b>'.$Row['UserNick'].'</b> '.ChooseSex($Row['UserSex']).' <b>'.$Row['UserAverageMark'].'</b></div>';
echo '<div width="200"><img src="profiles/'.$Row['UserID'].'/photos/mini/'.$Row['UserPhotoDefault'].'.jpg" alt="" /></div>'; echo '<div width="200">'.Age
($Row['UserBirthDate']).' lat</div>'; echo '<div width="200">'.$Row['UserLocCity'].' ('.$Row['UserLocProvince'].')</div>'; echo '<div width="200">'.$Row['UserEmail'].'</div>'; echo '<div width="200">'.$Row['UserGG'].'</div>'; echo '<div width="200">'.$Row['UserSkype'].'</div>'; echo '<div width="200">'.Timer
($Row['UserLastActive'],'NOW').'</div> </div>';
}
} else echo 'Nie znaleziono osoby odpowiadającej podanym kryteriom.'; }
break;}
?>
Nie działa, jeśli nacisnę na 2 stronę wyskakuje błąd:
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/teodor/public_html/konto/engine.class.php on line 85
Nie znaleziono osoby odpowiadającej podanym kryteriom. "
Prosze nie pisać, że może funkcja ta jest zła, bo zawsze i wszedzie chodziła, problem może być z zapytaniem.
Proszę o pomoc