开发者

MYSQL select option values question? Number or String?

开发者 https://www.devze.com 2023-04-01 02:12 出处:网络
Just a quick question. I am developing a php / mysql custom event page. I am stuck on the Select Values when \"submitting a record\" ??

Just a quick question.

I am developing a php / mysql custom event page. I am stuck on the Select Values when "submitting a record" ??

This is what I have now:

<select name="event_type" id="dis1">
                    <option value="Mtn. Bike">Mtn. Bike<开发者_开发百科;/option>
                    <option value="Road">Road</option>
                    <option value="Cyclocross">Cyclocross</option>
                </select>

Is this sufficient?

Should I do something like this instead?

 <select name="event_type" id="dis1">
                        <option value="1">Mtn. Bike</option>
                        <option value="2">Road</option>
                        <option value="3">Cyclocross</option>
                    </select>

Not sure if it really matters, what do you guys think?


It should be a numeric representation. It is more elegant when these are foreign keys.


It's difficult to say without knowing how you are using the data.

Generally speaking, if you're...

  • Sending an email, then the first is easiest.
  • Saving to a relational database), the second option is preferred.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号