title: How to pass value from MySQL to go template
body: <p>This struct to pass value to template</p>
  
  <pre><code>type Entry struct {
      Name, Mes string
  }
  </code></pre>
  
  <p>This function to handle with <code>HandleFunc("/", mysqlWithTempl)</code></p>
  
  <pre><code>func mysqlWithTempl(w http.ResponseWriter, r *http.Request) {
  
      // Open database
      con, err := sql.Open("mymysql", dbName+"/"+dbUserName+"/"+dbPassword)
      if err != nil {
          panic(err)
      }
  
      // Close database 
      defer con.Close()
  
      //query
      rows, err := con.Query("select name, message from entry")
  
      tRes := Entry{}
  
      //fetch result
      for rows.Next() {
          var name, message string
          rows.Scan(&amp;name, &amp;message)
          tRes.Name = name
          tRes.Mes = message
      }
      index.Execute(w, tRes)
  }
  </code></pre>
  
  <p>and this template </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt; Test &lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;section id="contents"&gt;
          &lt;p&gt; {{.Mes}} {{.Name}} &lt;/p&gt;
         &lt;/section&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>my ask how can fetch more value from mysql and pass it to template</p>
  
  <p>When try </p>
  
  <pre><code> for rows.Next() {
              var name, message string
              rows.Scan(&amp;name, &amp;message)
              tRes.Name = name
              tRes.Mes = message
  index.Execute(w, tRes)
          }
  </code></pre>
  
  <p>all result fetched but every thing repeated  </p>