LJackson

05-05-2009, 11:52 PM

Hi all,

i have what looks to be complicated if statments which im sure can be condensed much smaller

here is the first if statment which works

if($itemno <= 9){

$itemtype = "DVD";

}

elseif ($itemno >=10 AND $itemno <=18){

$itemtype = "CD";

}

elseif ($itemno >=19 AND $itemno <=27){

$itemtype = "Video Games";

}

elseif ($itemno >=28 AND $itemno <=36){

$itemtype = "Blu-Ray";

}

elseif ($itemno >=37 AND $itemno <=45){

$itemtype = "Books";

}

can the above be reduced to get the same result ?

and the second if statment which does not work for some reason

if($itemno >=1 AND $itemno <=3) or ($itemno >=10 AND $itemno <=12) or ($itemno >=19 AND $itemno <=21) or ($itemno >=28 AND $itemno <=30) or ($itemno >=37 AND $itemno <=39){

$subcat = "Bestsellers";

}

elseif($itemno >=4 AND $itemno <=6) or ($itemno >=13 AND $itemno <=15) or ($itemno >=22 AND $itemno <=24) or ($itemno >=31 AND $itemno <=33) or ($itemno >=40 AND $itemno <=42){

$subcat = "New Releases";

}

elseif($itemno >=7 AND $itemno <=9) or ($itemno >=16 AND $itemno <=18) or ($itemno >=25 AND $itemno <=27) or ($itemno >=34 AND $itemno <=36) or ($itemno >=43 AND $itemno <=45){

$subcat = "Gifted";

}

again if this can be condensed and corrected i'd really appreciate it :)

many thanks

Luke

i have what looks to be complicated if statments which im sure can be condensed much smaller

here is the first if statment which works

if($itemno <= 9){

$itemtype = "DVD";

}

elseif ($itemno >=10 AND $itemno <=18){

$itemtype = "CD";

}

elseif ($itemno >=19 AND $itemno <=27){

$itemtype = "Video Games";

}

elseif ($itemno >=28 AND $itemno <=36){

$itemtype = "Blu-Ray";

}

elseif ($itemno >=37 AND $itemno <=45){

$itemtype = "Books";

}

can the above be reduced to get the same result ?

and the second if statment which does not work for some reason

if($itemno >=1 AND $itemno <=3) or ($itemno >=10 AND $itemno <=12) or ($itemno >=19 AND $itemno <=21) or ($itemno >=28 AND $itemno <=30) or ($itemno >=37 AND $itemno <=39){

$subcat = "Bestsellers";

}

elseif($itemno >=4 AND $itemno <=6) or ($itemno >=13 AND $itemno <=15) or ($itemno >=22 AND $itemno <=24) or ($itemno >=31 AND $itemno <=33) or ($itemno >=40 AND $itemno <=42){

$subcat = "New Releases";

}

elseif($itemno >=7 AND $itemno <=9) or ($itemno >=16 AND $itemno <=18) or ($itemno >=25 AND $itemno <=27) or ($itemno >=34 AND $itemno <=36) or ($itemno >=43 AND $itemno <=45){

$subcat = "Gifted";

}

again if this can be condensed and corrected i'd really appreciate it :)

many thanks

Luke