SILLY DOUBT

General discussions related to php

Moderators: macek, egami, gesf

smdrafiqq
New php-forum User
New php-forum User
Posts: 1
Joined: Fri Jul 20, 2012 5:09 am

SILLY DOUBT

Postby smdrafiqq » Fri Jul 20, 2012 5:12 am

Actually in a drop down field,The first option is "select" i set 0 for this option, next i will show some items from db. The client asked me to add the new item at the end of the drop down and which is also the default one... for this what value is I have to give to this default item?

If I give value in number, thats is something like 1 or else, at this time we know that it is conflict with db items which is shown in this same drop down.

So i if i give the value is varchar means some like "default2", at this we have to change the date type into varchar in db.. Is this way is right> or any other option is there?

Any suggestions?

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: SILLY DOUBT

Postby johnj » Fri Jul 20, 2012 7:34 am

Well, if the option is mapped to the table value then you have to give one of those values. First add this to the table and then use that value.

For now, maybe you can use '-1' as an option for this.

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: SILLY DOUBT

Postby Nullsig » Fri Jul 20, 2012 8:56 am

To elaborate on JohnJ's response. Your default option should be a value that cannot exist in the table field that generates the rest of your results. If you are using only positive integers in the table then negative numbers are good. If you are using items from the full integer range, then you should use a string value. So on and so forth.

Once you submit the form that contains this select box you need to manually handle the catch for whatever value you have set. So if -1 is your value you will need to say

"If submitted value is -1 then create a new record else handle submission as normal"

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: SILLY DOUBT

Postby johnj » Sat Jul 21, 2012 5:41 am

thanks Nullsig.


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests