Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

How can I read mysql data in a variable

Codes here !

Moderators: macek, egami, gesf

How can I read mysql data in a variable

Postby bram » Thu Jan 02, 2003 1:37 am

Dear ,

I have search a lot about a way to read data from a mysql database in a bash variable but find no solution, i hope someone can help me with this?
i connect in bash to mysql:

mysql -uroot -pPassword -DtblTable -e "select groeps from yblTable;"

I need the result of this select query in a variable groeps($groeps).

kind regards,

bram
bram
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jan 02, 2003 1:30 am

bash variable

Postby jemy » Thu Jan 02, 2003 8:40 am

hi,

is that right?
You are looking for a bash script, which takes a variable out of mysql...
Something like that, maybe:

#!/bin/sh
# database test

test1=(`mysql -uroot -pPassword -DtblTable -e "select groeps from yblTable;"``)
echo
echo "${test1[1]}"
echo
jemy
New php-forum User
New php-forum User
 
Posts: 6
Joined: Thu Jan 02, 2003 5:27 am
Location: Munich / Germany

Re: bash variable

Postby bram » Thu Jan 02, 2003 9:03 am

:) Thanks Jamy!

It works!

kind regards,

bram
bram
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jan 02, 2003 1:30 am


Return to mySQL & php coding

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron