Input from option to database

Roka

Well-known member
Hi to all,
I developing one add-on and i have one question.

So if possibility to insert data to database from option?
e.x
Screenshot_1.webp

i have two option:

1. one text field
2. radio button with two option
(Same from inage above)

My database table is:

Code:
CREATE TABLE IF NOT EXISTS `xf_addon1` (
  `news_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(128) NOT NULL,
  `show_description` tinyint(3) unsigned NOT NULL,


  PRIMARY KEY (`news_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
Can i make insert input from field direct to 'name' and from radio button direct to 'show_description' ?

Thank you
 
You can get the XF options using XenForo_Application::getOptions()
Use magic accessors (if you like to call that, they have a real name) to access the options field. e.g. $options->theOptionID
Then run a db query as normal to put it in.
 
Why not? You'd just grab the values like @Robust describes and use a regular insert/update query to write to the database table.
 
Back
Top Bottom