Forum: Ruby mysql result is showing empty

Posted by Ferdous ara (ferdous)
on 2012-10-01 22:56
Hi
Bellow script.,
when i run the script. it does not show any output .

#!/usr/bin/ruby
require 'cgi'
require 'mysql'
cgi = CGI.new

m = Mysql.new("localhost","root","","fosiul")
r = m.query("SELECT * FROM dc")

puts cgi.header

puts "<html><body>

        <select>
                r.each_hash do |f|
                        <option> #{f['dc']}</option>
                end
                </select>
      </body></html>"

where i am doing wrong ???
Please let me know
Thanks
Posted by Sam Duncan (Guest)
on 2012-10-01 23:03
(Received via mailing list)
On 10/02/2012 09:56 AM, Ferdous ara wrote:
> r = m.query("SELECT * FROM dc")
>        </body></html>"
>
> where i am doing wrong ???
> Please let me know
> Thanks
>
Does this work?

...
puts "<html><body><select>"
r.each_hash do |f|
     puts "<option>#{f['dc']}</option>"
end
puts "</select></body></html>"
...


Sam
Posted by Ferdous ara (ferdous)
on 2012-10-01 23:11
S
> ...
> puts "<html><body><select>"
> r.each_hash do |f|
>      puts "<option>#{f['dc']}</option>"
> end
> puts "</select></body></html>"
> ...
>
>
> Sam

Hi thanks

its works, So i was missing puts
Posted by Ferdous ara (ferdous)
on 2012-10-02 00:13
Hi just a quick question

if i want to add an external css file with this script
how will i add that ??
whats the procedure ??

Thanks
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.