html - What is wrong with my CGI script to print MySQL data? -


i want display data mysql database in browser, using ruby cgi script.

the problem have displaying data; displays title column, , 1 cell , nothing price , isbn columns.

i used "title varchar, price decimal(10,2), isbn integer" create table.

i tried displaying price , isbn first 2 columns don't print, data in database.

#!/usr/bin/env ruby  require 'mysql2' require 'cgi'  client = mysql2::client.new(   :host => "localhost",   :database => "tempdb",   :username => "user",   :password => "pass"     ) results = client.query("select * mytable")  cgi = cgi.new  puts cgi.header  puts "<table border='1'>   <tr>     <th>title</th>     <th>price</th>     <th>isbn</th>   </tr>"  results.each |row|    puts "<tr>"   puts "<td>" + row["title"] + "</td>"   puts "<td>" + row["price"] + "</td>"   puts "<td>" + row["isbn"] + "</td>"   puts "</tr>"  end  puts "</table>"; 

fixed "#{row["price"].to_f}". thanks!


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -