您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

搜索排序问题

2025/11/9 21:49:45发布12次查看
交友网站搜索会员怎样使没形象照的会员排在有形象照会员后面.在最后面我加上了order by  avatarflag desc语句.搜索时报错:parse error: syntax error, unexpected t_string, expecting ')' in e:\phpnow-1.5.6\htdocs\source\service\index\service.user.php on line 147
报错行就是最后一行:order by  avatarflag desc.谁能帮忙看下上面的错在哪? 搜索代码如下:
public function validsearch( )
{
$args = array( );
$countwhere = ;
$s_searchtype = xrequest::getargs( s_searchtype );
$s_sex = xrequest::getint( s_sex );
$s_sage = xrequest::getint( s_sage );
$s_eage = xrequest::getint( s_eage );
$s_dist1 = xrequest::getint( s_dist1 );
$s_dist2 = xrequest::getint( s_dist2 );
$s_dist3 = xrequest::getint( s_dist3 );
$s_lovesort = xrequest::getint( s_lovesort );
$s_sheight = xrequest::getint( s_sheight );
$s_eheight = xrequest::getint( s_eheight );
$s_ssalary = xrequest::getint( s_ssalary );
$s_esalary = xrequest::getint( s_esalary );
$s_sedu = xrequest::getint( s_sedu );
$s_eedu = xrequest::getint( s_eedu );
if ( $s_searchtype == adv )
{
$s_marry = xrequest::getcomints( s_marry );
$s_havechild = xrequest::getcomints( s_havechild );
}
else
{
$s_marry = xrequest::getargs( s_marry );
$s_havechild = xrequest::getargs( s_havechild );
}
$s_house = xrequest::getint( s_house );
$s_car = xrequest::getint( s_car );
$s_avatar = xrequest::getint( s_avatar );
$args = array(
s_sex => $s_sex,
s_sage => $s_sage,
s_eage => $s_eage,
s_dist1 => $s_dist1,
s_dist2 => $s_dist2,
s_dist3 => $s_dist3,
s_lovesort => $s_lovesort,
s_sheight => $s_sheight,
s_eheight => $s_eheight,
s_ssalary => $s_ssalary,
s_esalary => $s_esalary,
s_sedu => $s_sedu,
s_eedu => $s_eedu,
s_marry => $s_marry,
s_havechild => $s_havechild,
s_house => $s_house,
s_car => $s_car,
s_avatar => $s_avatar
);
$sql = ;
if ( 0  {
$sql .=  and v.gender='.$s_sex.';
$countwhere .=  and ps.gender='.$s_sex.';
}
if ( 0  {
$year = date( y, time( ) );
$sageline = $year - $s_eage;
$eageline = $year - $s_sage;
$sql .=  and p.ageyear >= .$sageline. and p.ageyear  $countwhere .=  and ps.ageyear >= .$sageline. and ps.ageyear  }
if ( 0  {
$sql .=  and p.provinceid='.$s_dist1.';
$countwhere .=  and ps.provinceid='.$s_dist1.';
}
if ( 0  {
$sql .=  and p.cityid='.$s_dist2.';
$countwhere .=  and ps.cityid='.$s_dist2.';
}
if ( 0  {
$sql .=  and p.distid='.$s_dist3.';
$countwhere .=  and ps.distid='.$s_dist3.';
}
if ( 0  {
$sql .=  and p.lovesort='.$s_lovesort.';
$countwhere .=  and ps.lovesort='.$s_lovesort.';
}
if ( 0  {
$sql .=  and p.height >= .$s_sheight. and p.height  $countwhere .=  and ps.height >= .$s_sheight. and ps.height  }
if ( 0  {
$sql .=  and p.salary >= .$s_ssalary. and p.salary  $countwhere .=  and ps.salary >= .$s_ssalary. and ps.salary  }
if ( 0  {
$sql .=  and p.education >= .$s_sedu. and p.education  $countwhere .=  and ps.education >= .$s_sedu. and ps.education  }
if ( true === xvalid::iscomchar( $s_marry ) )
{
$sql .=  and p.marrystatus in (.$s_marry.);
$countwhere .=  and ps.marry in (.$s_marry.);
}
if ( true === xvalid::iscomchar( $s_havechild ) )
{
$sql .=  and p.childrenstatus in (.$s_havechild.);
$countwhere .=  and ps.child in (.$s_havechild.);
}
if ( 0  {
$sql .=  and p.housing='.$s_house.';
$countwhere .=  and ps.house='.$s_house.';
}
if ( 0  {
$sql .=  and p.caring='.$s_car.';
$countwhere .=  and ps.car='.$s_car.';
}
if ( $s_avatar == 1 )
{
$sql .=  and v.avatar != '' and v.avatarflag = '1';
$countwhere .=  and ps.avatar='1';
}
return array(
$sql,
$countwhere,
$args
order by  avatarflag desc 
);
}
回复讨论(解决方案) 代码调试中检查一下实际的sql语句是什么。
if ( $s_avatar == 1 )
{
$sql .=  and v.avatar != '' and v.avatarflag = '1';
$countwhere .=  and ps.avatar='1';
}
只有这个条件满足的时候,才有avatarflag 
order by avatarflag , 是不是要加上别名:v.
最好把完整的sql语句打出来,看看就知道了。
帮忙看下这个程序哪里错了.网站运行时报错:parse error: syntax error, unexpected t_constant_encapsed_string, expecting t_string or t_variable or '$' in e:\phpnow-1.5.6\htdocs\source\action\index\action.user.php on line 51
第51行代码是unset (service) ;
代码如下:
private function _unset( )
{
unset (service) ;
}
private function _getlistitems( )
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product