|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Problem with IF statement
Hi,
I have a dropdown box like this which calls some javascript: <select name="<?php echo $row["itemId"]; ?>" onChange="UpdateQty(this)"> <?php for($i = 1; $i <= 10; $i++) { echo "<option "; if($row["qty"] == $i) { echo " SELECTED "; } echo ">" . $i . "</option>"; } ?> </select> which is shown in a table along side each record listed. However i want to only show it if say if ($amount > 1) otherwise i will echo the value 1. I have been trying to build an if else statement around this but am struggling getting quotes/brackets right. Any help much appreciated |
|
#2
|
||||
|
||||
|
Something like this?
PHP Code:
|
|
#3
|
|||
|
|||
|
thanks for having a go but getting the dreaded:
parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in etc etc error for the if($row["qty"] == $i) line |
|
#4
|
||||
|
||||
|
In the 'selected="selected"' line, the backslash preceding the first quote in front of the second "selected" isn't rendering onscreen, though Itsacon appears to have included it. Add a backslash in front of that quote to escape it.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#5
|
||||
|
||||
|
Exactly, and I forgot a quote on the 7th line (in the <option> tag), this is the correct code:
PHP Code:
|
|
#6
|
|||
|
|||
|
Quote:
Works great now. Thanks both of you for your help very much appreciated. |
|
#7
|
||||
|
||||
|
You're welcome.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Problem with IF statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|