Conditional IF statement for the value of DD Menu

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
guyver4mk
Forum Newbie
Posts: 7
Joined: Sun Jun 14, 2009 7:32 am

Conditional IF statement for the value of DD Menu

Post by guyver4mk »

Hello All,

I'm hoping someone can help me, I've been racking my brains over this for the best part of 2 weeks now, I have dropdown menus on my MIDI Cart store, which, when selected, specify the quantity of the items.
The problem now is that due to the way the name of the quantity is written, there is no way that I can use that to specify the price, which is what i need.
Let me give an example to explain this better;

echo "
<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\"><B>$txt_order</B></FONT><BR>
<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\"><B><SELECT name=\"id$row[2]quant\" class=\"field\" width=\"50\">
<OPTION>Select Quantity</OPTION>

<OPTION value=\"$row[145]\">3 Months &nbsp;$txt_currency</B> &nbsp;&pound;$row[140]</OPTION><P>ss

<OPTION value=\"$row[146]\">6 Months &nbsp;$txt_currency</B>&nbsp;&pound;$row[141]<P>

<OPTION value=\"$row[147]\">12 Months&nbsp;$txt_currency</B>&nbsp;&pound;$row[142]<P>

</SELECT>

As you can see from the above, the value of the option is specified, but when selected it parses the value to a name tag of "id$row[2]quant" which I cannot then use in PHP.

for example I have tried the following IF Statements to try getting this to work;

1:

if('id$row[2]quant' == "30p"){

$price = $row[140];
}
else if('id$row[2]quant' == "90p"){

$price = $row[141];
}

else if('id$row[2]quant' == "180p"){

$price = $row[142];
}

else { $price = "0"}

2:

if($_SESSION['id$row[2]quant'] == "30p"){

$price = $row[140];
}
else if($_SESSION['id$row[2]quant'] == "90p"){

$price = $row[141];
}

else if($_SESSION['id$row[2]quant'] == "180p"){

$price = $row[142];
}

else { $price = "0"}

3:
if($_GET['id$row[2]quant'] == "30p"){

$price = $row[140];
}
else if($_GET['id$row[2]quant'] == "90p"){

$price = $row[141];
}

else if($_GET['id$row[2]quant'] == "180p"){

$price = $row[142];
}

else { $price = "0"}.

All to no avail.

Can anyone help with this problem??

Thanks
Post Reply