newman445617 Posted July 27, 2009 Share Posted July 27, 2009 <tr> <td><b>Forum Skin Style:</b></td> <td> <select name="skinstyle"> <option value="0">Default</option> <option value="1">Light Blue</option> <option value="2">Sunset</option> <option value="3">Beautiful Blue</option> </select> </td> </tr> my field name is "skinstyle" so whenever somone chooses it updates mysql for value = whatever 0 1 2 or 3.. But I need it to say selected="selected" next to which one they choose so they can remember. Im currently using this way but will make it php slower? if ($Profile['skinstyle'] == "0") $5 = "selected="selected""; if ($Profile['skinstyle'] == "1") $6 = "selected="selected""; then i put <option value="0" $6>Default</option> For each one.. isn't that slow? better way? Thx Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/ Share on other sites More sharing options...
newman445617 Posted July 27, 2009 Author Share Posted July 27, 2009 No one can help me? wow Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884372 Share on other sites More sharing options...
.josh Posted July 27, 2009 Share Posted July 27, 2009 be more patient? Are you hardcoding the options, or are they stored in your db or something and you loop through echoing them out? If so, put a condition in the loop and check for it. If not, put the options in an array, loop through it and check it. Example: $options = array('a','b','c','d','e'); $storedOption = 'c'; foreach($options as $option) { $selected = ($option == $storedOption)? " selected='selected'" : ""; echo "<option value='$option'$selected>$option</option>"; } Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884374 Share on other sites More sharing options...
Philip Posted July 27, 2009 Share Posted July 27, 2009 I find it easier to do the following, especially when you have a lot of entries: <select name="skinstyle"> <?php $options = array( 'Default' => 0, 'Light Blue' => 1, 'Sunset' => 2, 'Beautiful Blue' => 3, ); foreach($options as $text => $value) { echo '<option value="'.$value.'"'; if($Profile['skinstyle'] == $value) echo ' selected="selected"'; echo '>'.$text.'</option>'; } ?> </select> Edit: quite similar to CV's, just with keys/values for the options. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884376 Share on other sites More sharing options...
newman445617 Posted July 28, 2009 Author Share Posted July 28, 2009 be more patient? Are you hardcoding the options, or are they stored in your db or something and you loop through echoing them out? If so, put a condition in the loop and check for it. If not, put the options in an array, loop through it and check it. Example: $options = array('a','b','c','d','e'); $storedOption = 'c'; foreach($options as $option) { $selected = ($option == $storedOption)? " selected='selected'" : ""; echo "<option value='$option'$selected>$option</option>"; } ya right now i have all this.. ($Profile['skinstyle']=='0')? $i = "selected":""; ($Profile['skinstyle']=='1')? $i1 = "selected":"";($Profile['skinstyle']=='2')? $i2 = "selected":""; ($Profile['skinstyle']=='3')? $i3 = "selected":"";($Profile['skinstyle']=='4')? $i4 = "selected":"";($Profile['skinstyle']=='5')? $i5 = "selected":"";($Profile['skinstyle']=='6')? $i6 = "selected":""; rofl.. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884390 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 umm...I think you're missing the point... Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884394 Share on other sites More sharing options...
newman445617 Posted July 28, 2009 Author Share Posted July 28, 2009 umm...I think you're missing the point... My way works but will make php sloweR? Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884431 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 no...my way works just fine. You just failed to understand and apply the principle. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884432 Share on other sites More sharing options...
newman445617 Posted July 28, 2009 Author Share Posted July 28, 2009 no...my way works just fine. You just failed to understand and apply the principle. u just failed again to answer my question.. will it make it go sloweR? i can't apply your code bcz mine has EOF and while function doesnt work like that.. i use {$Profile['varable']} to get my code not simple php.. wow Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884438 Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 i use {$Profile['varable']} to get my code not simple php. And that's not PHP code ? no...my way works just fine. You just failed to understand and apply the principle. I agree with CV on this one.. if you understand the code you and adapt it to suite, PS: i think everyone in this thread is thinking WOW but at your replies Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884445 Share on other sites More sharing options...
newman445617 Posted July 28, 2009 Author Share Posted July 28, 2009 i use {$Profile['varable']} to get my code not simple php. And that's not PHP code ? no...my way works just fine. You just failed to understand and apply the principle. I agree with CV on this one.. if you understand the code you and adapt it to suite, PS: i think everyone in this thread is thinking WOW but at your replies I could careless what people think haha look at u.. your prob what 25? lol no life im only 15 Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884449 Share on other sites More sharing options...
Philip Posted July 28, 2009 Share Posted July 28, 2009 I could careless what people think hahaAnd you're the type to come back in a few years and beg to have your profile & posts deleted for looking like an idiot. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884457 Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 Owww goodie A personal attack! You sure your 15.. and not 12.. then again 15 is still pretty immature, yeah I have No life, none what so ever.. its not as if I can go out after 8pm, or drive or go clubbing or drink or you know have fun, have my own place, or choose where I go on holiday. NONE of that stuff.. Oh wait.. that's you! the fact is simple.. you don't even have a life yet, you think you know it all, just like every 15 year old does, but you are so wrong, With that out of the way (and I won't respond to another one), I'll take the high ground, Look at KingPhilip code and attempt to adapt it, to fit your needs, if you get stuck.. post what you have so far and we will try to help! Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884463 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 no...my way works just fine. You just failed to understand and apply the principle. u just failed again to answer my question.. will it make it go sloweR? i can't apply your code bcz mine has EOF and while function doesnt work like that.. i use {$Profile['varable']} to get my code not simple php.. wow You can apply the principle to any loop. In fact, the only way to apply the principle is with a loop. I assure you, the principle will apply just fine to your while loop looking for an EOF. You are just failing to understand what is going on with the code or how to apply it to your own. But instead of saying "Hey, I think that's what I need, but I'm not sure how to make it work with my specific situation (as opposed to the example I gave you..you do know what an example is, right?), here's what I'm trying, what am I doing wrong?" you decide to blow it off and mock people. You were the one who came here looking for help, remember? Apparently this is another principle you fail to grasp: don't bite the hand that feeds you. Attitudes like this are not what convince people they should even give you the time of day, much less actually help you. And as far as thinking that us "older" people have no lives because we code: You do know that there are plenty of careers out there and real money to be made doing it, right? Decent money. And a lot more respectable than the McJob you're hoping to some day work at. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884467 Share on other sites More sharing options...
newman445617 Posted July 28, 2009 Author Share Posted July 28, 2009 no...my way works just fine. You just failed to understand and apply the principle. u just failed again to answer my question.. will it make it go sloweR? i can't apply your code bcz mine has EOF and while function doesnt work like that.. i use {$Profile['varable']} to get my code not simple php.. wow You can apply the principle to any loop. In fact, the only way to apply the principle is with a loop. I assure you, the principle will apply just fine to your while loop looking for an EOF. You are just failing to understand what is going on with the code or how to apply it to your own. But instead of saying "Hey, I think that's what I need, but I'm not sure how to make it work with my specific situation (as opposed to the example I gave you..you do know what an example is, right?), here's what I'm trying, what am I doing wrong?" you decide to blow it off and mock people. You were the one who came here looking for help, remember? Apparently this is another principle you fail to grasp: don't bite the hand that feeds you. Attitudes like this are not what convince people they should even give you the time of day, much less actually help you. And as far as thinking that us "older" people have no lives because we code: You do know that there are plenty of careers out there and real money to be made doing it, right? Decent money. And a lot more respectable than the McJob you're hoping to some day work at. i didn't even read it.. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884471 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 Yes I know. You've been taught to only be able to process up to 130 characters. It's not your fault you were raised by a TV inst Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884473 Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 Okay.. well I'm out, His a Troll, I am not going to feed, Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884486 Share on other sites More sharing options...
akitchin Posted July 28, 2009 Share Posted July 28, 2009 for the record, the expression is "i COULDN'T care less." when you say "i could care less" it implies being capable of caring less than you currently do, which means you care at least a little bit. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884491 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 for the record, the expression is "i COULDN'T care less." when you say "i could care less" it implies being capable of caring less than you currently do, which means you care at least a little bit. Or taken as-is, it could be an implied threat. As in, "The fact that I'm not caring should be doing some damage to you, otherwise I would not be doing it. Keep it up and I will do more damage by not caring enough to " edit: Aww, I was hoping to have a bit more fun with him I guess it's his bedtime. "Don't forget to brush your teeth! Daddy will be in in a minute to tuck you in and give you a nite-nite kiss!" Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884504 Share on other sites More sharing options...
newman445617 Posted July 28, 2009 Author Share Posted July 28, 2009 for the record, the expression is "i COULDN'T care less." when you say "i could care less" it implies being capable of caring less than you currently do, which means you care at least a little bit. Or taken as-is, it could be an implied threat. As in, "The fact that I'm not caring should be doing some damage to you, otherwise I would not be doing it. Keep it up and I will do more damage by not caring enough to " edit: Aww, I was hoping to have a bit more fun with him I guess it's his bedtime. "Don't forget to brush your teeth! Daddy will be in in a minute to tuck you in and give you a nite-nite kiss!" hhaah come to my house in real life bro i'll kill you i'll slit ur throat kid and tie u in the back seat of a car and slam your head against the php bible u dumb arabic COON waaaaaah I can't think of anything else to say so i'm going to resort to being a potty mouth waaah waah waaah! haha owned nigger Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884514 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 Son, I told you it's time for bed. Now go back to your room, turn off the light and go nite-nite. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884516 Share on other sites More sharing options...
akitchin Posted July 28, 2009 Share Posted July 28, 2009 i think that's all there is to see here. move along, folks. Link to comment https://forums.phpfreaks.com/topic/167687-is-there-a-easier-way-or-more-efficiant/#findComment-884517 Share on other sites More sharing options...
Recommended Posts