LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-04-2010, 06:31 PM   #1
eoc92866
LQ Newbie
 
Registered: Oct 2010
Posts: 24

Rep: Reputation: 0
grabbing data and displaying an image


i am attempting to grab roughly 40 pieces of data that is a combination of 0 and 1 flags from mysql. based off of the 0 or 1... either pictA or pictB will be displayed.

can someone please assist me in evaluating my code? i believe the logic is incorrect.


PHP Code:
$status = `mysql -u username -ppassword -h x.x.x.x -e 'SELECT help FROM table' database`;

declare -
ARRAY

for ((
i=1i=$statusi++));
do
        echo ${ARRAY[$(
i)]}
done


if [${ARRAY[]} = ];
then
       
echo "<img src='pictA.gif'>";

else [${ARRAY[]} = 
];
       echo 
"<img src='pictB.gif'>";
fi 
 
Old 11-04-2010, 07:25 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Ummm ... w/ the square brackets in the if and the condition
tacked onto the else I'm wondering why it would produce anything
at all; that doesn't look like valid PHP.


Cheers,
Tink
 
Old 11-04-2010, 09:15 PM   #3
eoc92866
LQ Newbie
 
Registered: Oct 2010
Posts: 24

Original Poster
Rep: Reputation: 0
apologies, the code is actually written in bash.

Code:
$status = `mysql -u username -ppassword -h x.x.x.x -e 'SELECT help FROM table' database`;

declare -A ARRAY

for ((i=1; i=$status; i++));
do
        echo ${ARRAY[$(i)]}
done


if [${ARRAY[]} = 1 ];
then
       echo "<img src='pictA.gif'>";

else [${ARRAY[]} = 0 ];
       echo "<img src='pictB.gif'>";
fi
 
Old 11-04-2010, 11:30 PM   #4
alan99
Member
 
Registered: Mar 2010
Distribution: Debian
Posts: 180

Rep: Reputation: 31
What is declare? is that a bash statement

Last edited by alan99; 11-04-2010 at 11:32 PM.
 
Old 11-05-2010, 12:15 AM   #5
alan99
Member
 
Registered: Mar 2010
Distribution: Debian
Posts: 180

Rep: Reputation: 31
Quote:
Originally Posted by eoc92866 View Post
i am attempting to grab roughly 40 pieces of data that is a combination of 0 and 1 flags from mysql. based off of the 0 or 1... either pictA or pictB will be displayed.

can someone please assist me in evaluating my code? i believe the logic is incorrect.


PHP Code:
$status = `mysql -u username -ppassword -h x.x.x.x -e 'SELECT help FROM table' database`;

declare -
ARRAY

for ((
i=1i=$statusi++));
do
        echo ${ARRAY[$(
i)]}
done


if [${ARRAY[]} = ];
then
       
echo "<img src='pictA.gif'>";

else [${ARRAY[]} = 
];
       echo 
"<img src='pictB.gif'>";
fi 
first of all $status = will fail as $status will reference a variable, not declare one. It should be status=`statement`

Second you try to assign a index variable using $status. $status is not an integer. it will be a series of strings. First set returned are the column names of the table. next comes the rows of the table.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grabbing data and displaying an image eoc92866 Programming 9 11-07-2010 08:02 AM
ftp_fget problems grabbing text data from ftp file on LINUX machine nuebelhor Red Hat 1 10-12-2009 05:15 AM
Help with displaying an image in PHP pandersson61 Programming 3 07-31-2008 10:40 PM
grabbing data from a website secretlydead Linux - General 1 02-08-2008 11:14 AM
PHP: how can I return an image - not the html img src tag, but the image data BrianK Programming 3 05-18-2007 03:28 PM


All times are GMT -5. The time now is 08:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration