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
sell-traffic
Forum Commoner
Posts: 26 Joined: Thu Aug 05, 2004 9:35 pm
Post
by sell-traffic » Sat Sep 11, 2004 12:16 pm
Hi,
Not sure what's wrong with this code...
Code: Select all
<select name="select">
<option value="0" <? if ($row_orderdetail['status'] = 0) { echo "selected"; } ?> >Pending</option>
<option value="1" <? if ($row_orderdetail['status'] = 1) { echo "selected"; } ?> >Approved</option>
<option value="2" <? if ($row_orderdetail['status'] = 2) { echo "selected"; } ?> >Waiting For User Response</option>
<option value="3" <? if ($row_orderdetail['status'] = 3) { echo "selected"; } ?> >Fraudulent</option>
</select>
The test value is 0 right now, so the "Pending" option should be selected, but this is the HTML code that results...
Code: Select all
<select name="select">
<option value="0" >Pending</option>
<option value="1" selected >Approved</option>
<option value="2" selected >Waiting For User Response</option>
<option value="3" selected >Fraudulent</option>
</select>
Thus, it always shows "Fraudulent".
Thanks,
Josh
Last edited by
sell-traffic on Sat Sep 11, 2004 12:24 pm, edited 1 time in total.
sell-traffic
Forum Commoner
Posts: 26 Joined: Thu Aug 05, 2004 9:35 pm
Post
by sell-traffic » Sat Sep 11, 2004 12:23 pm
Resolved with the following...
Code: Select all
<select name="statusbox" title="<?php echo $row_orderdetail['status']; ?>">
<option value="0" <?php if (!(strcmp(0, $row_orderdetail['status']))) {echo "SELECTED";} ?>>Pending</option>
<option value="1" <?php if (!(strcmp(1, $row_orderdetail['status']))) {echo "SELECTED";} ?>>Approved</option>
<option value="2" <?php if (!(strcmp(2, $row_orderdetail['status']))) {echo "SELECTED";} ?>>Waiting For User Response</option>
<option value="3" <?php if (!(strcmp(3, $row_orderdetail['status']))) {echo "SELECTED";} ?>>Fraudulent</option>
</select>
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Sat Sep 11, 2004 12:57 pm
the matter was that you used wrong operator. '=' is assingment operator. to check for equality you would use '=='
Deemo
Forum Contributor
Posts: 418 Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC
Post
by Deemo » Sat Sep 11, 2004 5:06 pm
Code isnt always like you would type it in real life. For more help on operators, look
here