开发者

Storing multiple radio button data

I want to have radio buttons that tell my information where it should be displayed on certain pages, but I am unsure of how to store that information in the mySQL database. Can I just make 2 fields called开发者_Go百科 "Page" and "Section" and separate each value with a comma and have PHP read that back at the time so it knows where to display the information on the page? IF so, how can this be done?

Any other suggestions are appreciated to make this simpler!


It's much simpler than you probably think it is.

Have the radio buttons share a name, but have different values.

<input type="radio" name="some_var" value="one" />
<input type="radio" name="some_var" value="two" />

Then, on the PHP side, the variable $_REQUEST['some_var'] will contain the value "one" or "two" according to whichever is selected. (If neither is selected, the variable will not exist in $_REQUEST.)

From that point on, write to database like any other text field.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜