PDA

View Full Version : Help with IF statement


rjdineen
08-15-2010, 10:38 PM
Hello everyone

I have a droplist with a value of ALL. How do i construct an IF statement

if the ALL value is select. ie

IF ItemType = 'All'
then Variable = ('New','Used','Old')

could someone tell me if i am on the right lines.

Regards

Rob

edbr
08-16-2010, 02:06 AM
i dont think you will achieve what i think you want this way but

if(ItemType = 'All')
{
// your stuff
}

davidj
08-16-2010, 09:46 AM
(=) assignment
(==) test for equality
(===) test for equality and type


if(ItemType =='All')
{
// your stuff
}

davidj
08-16-2010, 09:48 AM
@ ed

http://163.32.57.3/blog/26/attachment/1232622278_0.jpg

edbr
08-16-2010, 10:02 AM
oh thats so sadly true

rjdineen
08-16-2010, 11:30 AM
Could someone give me an example of ( your stuff ) please
Im not quite sure of the sintax for dreamweaver.

Regards

Rob

davidj
08-16-2010, 02:20 PM
what are your mappings?

What do you want the variable to be assigned if the test == All

rjdineen
08-16-2010, 02:48 PM
Ok for example

I have a drop down list.

with values of. All, New, Second Hand, Very Old

when selecting the All value. I want this to open up the search to all

( New, Second Hand, Very Old )

The variable is AgeList. and the url property name is Age

davidj
08-16-2010, 04:28 PM
are you implementing this in a SQL query.

rjdineen
08-16-2010, 07:30 PM
o yes sorry

davidj
08-17-2010, 09:34 AM
if(isset($_POST['droplist'])){

// change tablefield to match your table column name convention.
switch($_POST['droplist']){

case 'All': $sql = "tablefield IN('New', 'Used', 'Old') "; break;
case 'New': $sql = "tablefield = 'New'"; break;
case 'Used': $sql = "tablefield = 'Used'"; break;
case 'Old': $sql = "tablefield = 'Old'"; break;

default: $sql = "tablefield IN('New', 'Used', 'Old') "; break;

}


}