Поиск в скрипте...

plumcake

Новичок
Поиск в скрипте...

Есть код поискового запроса:
PHP:
<?php
if (!$onlinetimeout) $onlinetimeout=60*3;$logt=time()-$onlinetimeout;
if ($page>999 or $page<1) $page=1;if (!$search) $page=0;
if (!$age1) $age1=0;
if (!$age2) $age2=999;
if ($search){
$c_pic="and m.id=pi.member and pi.type='Main' ";
$t_pic=", pictures pi";
$s_pic=", pi.id as pid, pi.picture as picture, pi.details as palt";
if (!$pictures) {
$c_pic="";
$t_pic="";
$s_pic="";
};
$c="m.id=p.id $c_pic";
if ($login) $c.="and m.login like '%$login%' ";
if ($fname) $c.="and m.fname like '%$fname%' ";
if ($lname) $c.="and m.lname like '%$lname%' ";
if ($country) $c.="and m.country like '%$country%' ";
if ($state) $c.="and m.state like '%$state%' ";
if ($city) $c.="and m.city like '%$city%' ";
if ($yahoo) $c.="and p.yahoo like '%$yahoo%' ";
if ($msn) $c.="and p.msn like '%$msn%' ";
if ($aol) $c.="and p.aol like '%$aol%' ";
if ($icq) $c.="and p.icq='$icq' ";
if ($onlinet) $c.="and p.ldate >=$onlinet ";
$age1=$age1+0;$age2=$age2+0;
if ($age1)  $c.="and (YEAR(CURRENT_DATE)-YEAR(p.birthdate)) - (RIGHT(CURRENT_DATE,5)<RIGHT(p.birthdate,5)) >=$age1 ";
if ($age2)  $c.="and (YEAR(CURRENT_DATE)-YEAR(p.birthdate)) - (RIGHT(CURRENT_DATE,5)<RIGHT(p.birthdate,5)) <=$age2 ";
if ($sex)   $c.="and p.sex='$sex' ";
if ($likes) $c.="and p.likes='$likes' ";
$height1=$height1+0;$height2=$height2+0;
if ($height1) $c.="and p.height >=$height1 ";
if ($height2) $c.="and p.height <=$height2 ";
$weight1=$weight1+0;$weight2=$weight2+0;
if ($weight1) $c.="and p.weight >=$weight1 ";
if ($weight2) $c.="and p.weight <=$weight2 ";
if ($maritalstatus) $c.="and p.maritalstatus='$maritalstatus' ";
if ($skin) $c.="and p.skin='$skin' ";
if ($eyes) $c.="and p.eyes='$eyes' ";
if ($hair) $c.="and p.hair='$hair' ";
if ($relationship) $c.="and p.relationship='$relationship' ";
if ($custom1) $c.="and p.custom1='$custom1' ";
if ($custom2) $c.="and p.custom2='$custom2' ";
if ($custom3) $c.="and p.custom3='$custom3' ";
if ($drinker) $c.="and p.drinker='$drinker' ";
if ($smoker)  $c.="and p.smoker='$smoker' ";
if ($religion) $c.="and p.religion='$religion' ";
if ($search==2) {
$c=$sessionc; };
$sessionc=$c;
$ssql="select m.id as id, m.login as login, m.country as country, m.state as state, m.city as city, (YEAR(CURRENT_DATE)-YEAR(p.birthdate)) - (RIGHT(CURRENT_DATE,5)<RIGHT(p.birthdate,5)) as age, p.ldate as ldate, p.details as details $s_pic from members m, profiles p $t_pic where $c ORDER BY m.login ASC LIMIT ".(($page-1)*10).", 10";
$r=q($ssql);?>
Дело в том 4то сам код заме4ательно работает, но недавно добавил в таблицу пару десятков пользователей у которых некоторые поля (в том 4исле и логин и/или пароль) могут равняться NULL. После этого я могу искать... и полу4ать результаты только из тех пользователей которые регистрировались сами... Как сделать так 4тоб он искал из всех пользователей БД(даже если некоторые их поля имеют зна4ения NULL).
Заранее спасибо!
 

plumcake

Новичок
Vetal
нет id не может,
все спасибо с этим уже разобрался =)

Еще один вопрос по запросу:
PHP:
if ($save)
	{
		q("update 'profiles' set yahoo='$yahoo', msn='$msn', icq='$icq', aol='$aol', birthdate='$birthdate', sex='$sex',
		likes='$likes', maritalstatus='$maritalstatus', height='$height', weight='$weight', skin='$skin', eyes='$eyes', hair='$hair',
		languages='$languages', details='$details', occupation='$occupation', ethnicity='$ethnicity', relationship='$relationship',
		religion='$religion', smoker='$smoker', drinker='$drinker', custom1='$custom1', custom2='$custom2', custom3='$custom3' where id='$auth'");
	}
		$p=f(q("select * from profiles where id='$auth'"));?>
вывод из базы работает заме4ательно :) а вот редактирование =(
Все по той же проблеме после добавления в базу перестал работать... где грабли?
 

Фанат

oncle terrible
Команда форума
где грабли, надо спрашивать не у нас, а у базы
 

amorfis

я стараюсь
Попробуй этот запрос примениь к базе. Может там несуществующая колонка или еще чего?
 
Сверху