MySql Select question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benwalsh
    New Member
    • Jan 2007
    • 1

    MySql Select question

    can any one tell me what may be wrong with this script I have written, excerpt following:

    [PHP]if($set ="yes"){ $query.="online = 'y'"; }
    if($lab !=""){ $query.=" AND Lab= '$lab'"; }
    if($parcel !=""){ $query.=" AND Parcel = '$parcel'"; }
    if($shape !=""){ $query.=" AND Shape = '$shape'"; }
    if($color !=""){ $query.=" AND Color = '$color'"; }
    if($clarity !=""){ $query.=" AND Clarity = '$clarity'"; }
    if($depth !=""){ $query.=" AND Depth = '$depth'"; }
    if($size !=""){ $query.=" AND Size = '$size'"; }
    if($polish !=""){ $query.=" AND Polish = '$polish'"; }
    if($culet !=""){ $query.=" AND Culet = '$culet'"; }
    if($fluorescenc e !=""){ $query.=" AND Fluorescence = '$fluorescence' "; }
    if($symmetry !=""){ $query.=" AND Symmetry = '$symmetry'"; }
    $query .= " AND Weight BETWEEN '$weight_sm' AND '$weight_big'";

    $result = mysql_query("SE LECT * FROM diamonds WHERE $query ORDER BY $orderby LIMIT $startrow, $limit")

    or die(mysql_error ());
    [/PHP]

    Wieght is all that is working for me?

    TIA Ben
  • khalidbaloch
    New Member
    • Oct 2006
    • 61

    #2
    Originally posted by benwalsh
    can any one tell me what may be wrong with this script I have written, excerpt following:

    [PHP]if($set ="yes"){ $query.="online = 'y'"; }
    if($lab !=""){ $query.=" AND Lab= '$lab'"; }
    if($parcel !=""){ $query.=" AND Parcel = '$parcel'"; }
    if($shape !=""){ $query.=" AND Shape = '$shape'"; }
    if($color !=""){ $query.=" AND Color = '$color'"; }
    if($clarity !=""){ $query.=" AND Clarity = '$clarity'"; }
    if($depth !=""){ $query.=" AND Depth = '$depth'"; }
    if($size !=""){ $query.=" AND Size = '$size'"; }
    if($polish !=""){ $query.=" AND Polish = '$polish'"; }
    if($culet !=""){ $query.=" AND Culet = '$culet'"; }
    if($fluorescenc e !=""){ $query.=" AND Fluorescence = '$fluorescence' "; }
    if($symmetry !=""){ $query.=" AND Symmetry = '$symmetry'"; }
    $query .= " AND Weight BETWEEN '$weight_sm' AND '$weight_big'";

    $result = mysql_query("SE LECT * FROM diamonds WHERE $query ORDER BY $orderby LIMIT $startrow, $limit")

    or die(mysql_error ());
    [/PHP]

    Wieght is all that is working for me?

    TIA Ben
    what is the problem ?

    Comment

    • subash
      New Member
      • Sep 2006
      • 32

      #3
      Hi,

      I think from your code - you may not able to get the online value on certain cases. Its because you have used

      [PHP] if($set ="yes"){ $query.="online = 'y'"; } [/PHP]

      So always the value has set to "yes"


      You need to change this as

      [PHP] if($set =="yes"){ $query.="online = 'y'"; } [/PHP]

      Are you clear with the comments? - Write back to me

      Subash :)

      Comment

      Working...