Thread: Colors/bold chars in a select?
Hi all! This is just a peregrine thought: is it at all possible to print (on screen) in bold chars/or colour the lines of a select result that satisfy a certain condition? Regards, Ennio -- [Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?// Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°) [Why use Win$ozz (I say) if ... "even a fool can do that. )=( Do something you aren't good at!" (as Henry Miller used to say) ]
> Hi all! > This is just a peregrine thought: > is it at all possible to print (on screen) in bold > chars/or colour the > lines of a select result that satisfy a certain > condition? > Regards, > Ennio it seems to me that the method woul dbe specific to whatever system you are using to display the data. eg, if the display is html, then you could include html (or some conversion that could be converted back to avoid scripting attacks) where applicable. you may also be able to display the text and apply regexes in order to identify the characters and then make them bold without the html in the db. perhaps a stored procedure could help with this, but i lack experience in that area as of now. this seems like more of an application problem than a db problem, though. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
* operationsengineer1@yahoo.com <operationsengineer1@yahoo.com> [130406, 13:49]: > > Hi all! > > This is just a peregrine thought: > > is it at all possible to print (on screen) in bold > > chars/or colour the > > lines of a select result that satisfy a certain > > condition? > > Regards, > > Ennio > > it seems to me that the method woul dbe specific to > whatever system you are using to display the data. > > eg, if the display is html, then you could include > html (or some conversion that could be converted back > to avoid scripting attacks) where applicable. > > you may also be able to display the text and apply > regexes in order to identify the characters and then > make them bold without the html in the db. > > perhaps a stored procedure could help with this, but i > lack experience in that area as of now. > > this seems like more of an application problem than a > db problem, though. > Mmmm... I fear that your last sentence is very true and unluckily enough is what I would need to accomplish my goal; I'm already getting a coloured display of the result of my selection ...; but let me explain better what I was thinking about, as I realize it was not very clear: Suppose the result of my select is a table like this: item ..... price_at_time_X ..... price_at_time_Y ------------------------------------------------------ aaaa 10.1245 12.13 bbbb 5.14 5.04 cccc 0.10 0.12 My question is: can I get a coloured evidence that time_Y prices of items 'aaaa' and 'bbbb' are higher than at time_X so as to get a more immediate evidence of what is going on? Think about stock prices, as an example ;-) [I've already arranged to have separate lists of all items with higher/lower prices, but was wondering whether there was any other possibility] Thanks for your answer, anyway. Regards, Ennio. -- [Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?// Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°) [Why use Win$ozz (I say) if ... "even a fool can do that. )=( Do something you aren't good at!" (as Henry Miller used to say) ]
> * operationsengineer1@yahoo.com > <operationsengineer1@yahoo.com> [130406, 13:49]: > > > Hi all! > > > This is just a peregrine thought: > > > is it at all possible to print (on screen) in > bold > > > chars/or colour the > > > lines of a select result that satisfy a certain > > > condition? > > > Regards, > > > Ennio > > > > it seems to me that the method woul dbe specific > to > > whatever system you are using to display the data. > > > > eg, if the display is html, then you could include > > html (or some conversion that could be converted > back > > to avoid scripting attacks) where applicable. > > > > you may also be able to display the text and apply > > regexes in order to identify the characters and > then > > make them bold without the html in the db. > > > > perhaps a stored procedure could help with this, > but i > > lack experience in that area as of now. > > > > this seems like more of an application problem > than a > > db problem, though. > > > > Mmmm... > I fear that your last sentence is very true and > unluckily enough is what > I would need to accomplish my goal; I'm already > getting a coloured > display of the result of my selection ...; but let > me explain better > what I was thinking about, as I realize it was not > very clear: > > Suppose the result of my select is a table like > this: > > item ..... price_at_time_X ..... > price_at_time_Y > ------------------------------------------------------ > aaaa 10.1245 12.13 > bbbb 5.14 5.04 > cccc 0.10 0.12 > > My question is: can I get a coloured evidence that > time_Y prices of > items 'aaaa' and 'bbbb' are higher than at time_X so > as to get a more > immediate evidence of what is going on? Think about > stock prices, as an > example ;-) > [I've already arranged to have separate lists of all > items with > higher/lower prices, but was wondering whether there > was any other > possibility] > i might be off base, but you could use your app to check the values and then apply a css span style if your criteria is met. if ($y > $x){ // you'd probably be checking // array values and running a for loop $y = '<span class = \'green\'> . $y . '</span>'; } echo $y; again, something similar tothis would work with php / html / css. i'm not sure what you are using. you might be able to use a stored procedure to prepend and append the span tags after doing the math - but i don't know that much about stored procedures. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
* operationsengineer1@yahoo.com <operationsengineer1@yahoo.com> [130406, 16:13]: > > * operationsengineer1@yahoo.com > > <operationsengineer1@yahoo.com> [130406, 13:49]: > > > > Hi all! > > > > This is just a peregrine thought: > [...] > > > > Suppose the result of my select is a table like > > this: > > > > item ..... price_at_time_X ..... > > price_at_time_Y > > > ------------------------------------------------------ > > aaaa 10.1245 12.13 > > bbbb 5.14 5.04 > > cccc 0.10 0.12 > > > > My question is: can I get a coloured evidence that time_Y prices of > > items 'aaaa' and 'bbbb' are higher than at time_X so as to get a > > more immediate evidence of what is going on? Think about stock > > prices, as an example ;-) > > [I've already arranged to have separate lists of all items with > > higher/lower prices, but was wondering whether there was any other > > possibility] > > > > i might be off base, but you could use your app to check the values > and then apply a css span style if your criteria is met. > > if ($y > $x){ // you'd probably be checking > // array values and running a for loop > $y = '<span class = \'green\'> . $y . '</span>'; > } > > echo $y; > I'll try to discover what a 'css span style' is ... > again, something similar tothis would work with php / html / css. i'm > not sure what you are using. > I'm using bash scripts which call psql commands (working in console, not xterm); so, I suppose I'd have to first save the query result in a temporary table/file and then run the loop on this table/file (no idea for the time being on how to do that ...). I've heard about php potential, but my learning curve would be too long; the same applies to html and css (this is a programming tool, I suppose?). > you might be able to use a stored procedure to prepend > and append the span tags after doing the math - but i > don't know that much about stored procedures. > Neither do I ;) Thanks for your hints: with further reading I'll try to get some result out of them. Best regards, Ennio. ------ PS: I won't be able to see any mail until next Tuesday. Happy Easter to all of you. -- [Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?// Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°) [Why use Win$ozz (I say) if ... "even a fool can do that. )=( Do something you aren't good at!" (as Henry Miller used to say) ]
* Ennio-Sr <nasr.laili@tin.it> [2006-04-14 23:27:38 +0200]: > I'm using bash scripts which call psql commands (working in console, not > xterm); so, I suppose I'd have to first save the query result in a > temporary table/file and then run the loop on this table/file (no idea > for the time being on how to do that ...). > I've heard about php potential, but my learning curve would be too long; > the same applies to html and css (this is a programming tool, I suppose?). So the output is coming to the terminal? There are control codes you can use to make text bold/colored on the terminal. For example... echo -e "\e[32;01mGreen Hello" should print out "Green Hello" in green text. You can probably find more examples in the scripts that your distribution uses to start various deamon processes (usually in /etc/init.d). This task sounds like a job for awk. The syntax of the script below might not be quite correct but you should be able to do something like... psql -f query.sql |awk ' { if($2 >= $1) print "\e[32;01m" $0 else print $0 } ' Hope this helps, Andy Chambers Send instant messages to your online friends http://uk.messenger.yahoo.com
* Andrew Chambers <andychambers2002@yahoo.co.uk> [150406, 12:31]: > * Ennio-Sr <nasr.laili@tin.it> [2006-04-14 23:27:38 +0200]: > ..... > This task sounds like a job for awk. The syntax of the script below > might not be quite correct but you should be able to do something > like... > > psql -f query.sql |awk ' { if($2 >= $1) print "\e[32;01m" $0 > else print $0 > } ' > Hi Andrew, thank you for your suggestion: I wouldn't expect it was possible to pipe the psql command output and was looking for a psql command ... Unfortunately, awk does the job perfectly in a test table (having only a few output fields) whereas it seems to get confused when I use it for the real table and with multiple conditions ( if .. do; else if .. do ; else do ). I'm reading man awk just now ... ;) Best regards, Ennio. -- [Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?// Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°) [Why use Win$ozz (I say) if ... "even a fool can do that. )=( Do something you aren't good at!" (as Henry Miller used to say) ]
* Ennio-Sr <nasr.laili@tin.it> [2006-04-20 22:40:40 +0200]: > Unfortunately, awk does the job perfectly in a test table (having > only a few output fields) whereas it seems to get confused when I use it > for the real table and with multiple conditions ( if .. do; else if .. > do ; else do ). I'm reading man awk just now ... ;) Once you've done that, if your still having difficulties, you might try comp.lang.awk for help with the awk specific stuff. There are also a few enthusiastic awk proponents on the gentoo forums (they use it quite a lot in their "ebuild" system). I'm glad I could help. Best Regards, Andy ___________________________________________________________ 24 FIFA World Cup tickets to be won with Yahoo! Mail http://uk.mail.yahoo.com
* Andrew Chambers <andychambers2002@yahoo.co.uk> [210406, 12:52]: > * Ennio-Sr <nasr.laili@tin.it> [2006-04-20 22:40:40 +0200]: > .... > Once you've done that, if your still having difficulties, you might try > comp.lang.awk for help with the awk specific stuff. There are also a > few enthusiastic awk proponents on the gentoo forums (they use it quite > a lot in their "ebuild" system). > OK, I'll do that. Thanks again, Ennio. -- [Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?// Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°) [Why use Win$ozz (I say) if ... "even a fool can do that. )=( Do something you aren't good at!" (as Henry Miller used to say) ]