Jump to content

Is there a Easier way? Or more efficiant..


newman445617

Recommended Posts

<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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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  :headslap: "

 

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
Share on other sites

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  :headslap: "

 

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
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.