title: updating selectInput in Shiny R with MySQL data from server
body: <p>I need to write some code, it is something like an internet journal. The problem is that I need to connect to my SQL database on a server, then download a table (<code>students</code>) and display the column of this table in the field <code>selectInput</code>. I want to store the table <code>students</code> to dataframe students and then display the column from this table in <code>ui.R</code> in <code>selectInput("student", "Имя:", "")</code>. Here is my code:</p>
  
  <pre><code>server.R
  
  library(shiny)
  library(RMySQL)
  
  courseDBChoise &lt;- function(course){
  courseDB &lt;- dbConnect(MySQL(), user="root", password="password",
                         host="111.111.111.1", db=course)
  dbSendQuery(conn=courseDB, "SET NAMES utf8")
  students &lt;&lt;- dbReadTable(conn = courseDB, "students")
  return(students)}
  
  
  shinyServer(
       function(input,output,session){
            test &lt;- reactive({courseDBChoise(input$course)})
            observe({
                 updateTextInput(session, "student", 
                                 value = test)
            })
  
       }
  )
  
  
  ui.R
  
  library(shiny)
  
  shinyUI(fluidPage(
       titlePanel("Журнал преподавателя"),
       sidebarPanel(
            h4("Пожалуйста, выберете курс, фамилию ученика и номер работы:"),
            br(),br(),
            selectInput("student", "Имя:", ""),
            selectInput("course", "Курс:",
                        list("Математика"="mathematics",
                             "Физика"="physics",
                             "Химия"="chemistry")),
            selectInput("homework","№ Работы",as.character(1:30)),
            br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(),
            img(src="head.png",height=75,width=75,align="center"),
            "ФФФХИ, МГУ, Москва"
            ),
       mainPanel(wellPanel(
            h4("Введите оценки, полученные за работу"),
            br(),
            fluidRow(
                 column(2,strong("1"),align="center"),
                 column(2,strong("2"),align="center"),
                 column(2,strong("3"),align="center"),
                 column(2,strong("4"),align="center"),
                 column(2,strong("5"),align="center"),
                 column(2,strong("6"),align="center")
                 ),
            fluidRow(
                 column(2,textInput("N1",label="",value=NA)),
                 column(2,textInput("N2",label="",value=NA)),
                 column(2,textInput("N3",label="",value=NA)),
                 column(2,textInput("N4",label="",value=NA)),
                 column(2,textInput("N5",label="",value=NA)),
                 column(2,textInput("N6",label="",value=NA))
                 ),
            br(),
            fluidRow(
                 column(2,strong("7"),align="center"),
                 column(2,strong("8"),align="center"),
                 column(2,strong("9"),align="center"),
                 column(2,strong("10"),align="center"),
                 column(2,strong("11"),align="center"),
                 column(2,strong("12"),align="center")
                 ),
            fluidRow(
                 column(2,textInput("N7",label="",value=NA)),
                 column(2,textInput("N8",label="",value=NA)),
                 column(2,textInput("N9",label="",value=NA)),
                 column(2,textInput("N10",label="",value=NA)),
                 column(2,textInput("N11",label="",value=NA)),
                 column(2,textInput("N12",label="",value=NA))
                 ),
            br(),
            submitButton("Занести оценки в журнал"), 
            align="center"
            ))
       )
  )
  </code></pre>