Home > Archive > PHP Programming > March 2005 > PHP newbie - Oracle spooled files and decode to PHP dynamic pages
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
PHP newbie - Oracle spooled files and decode to PHP dynamic pages
|
|
| apthorburn 2005-03-30, 3:56 pm |
| Hi,
As a bit of a PHP newbie I have a question. On our Intranet we have
staff listings which we want to move to dynamic pages. As part of the
SQL in the original pages we have a SQL decode (see below...)
I have been trying to replicate this approach in PHP but have come
across no logical solution. I am assuming that there will be a PHP
based solution?
Thanks in advance
Andrew
** CODE **
select '<TR class="'||decode(m.division,
'Administration','administration',
'Analytical','analytical',
'Aramark - Din Rm','aramark',
'BioSS','bioss',
'Ecological Sciences','ecosci',
'Environmental Sciences','envsci',
'Fellows/Associates','fellows',
'Human Dimensions','humdim',
'IFRU','ifru',
'Information Technology
Services','its',
'International Feed Resources
Unit','ifru',
'Isotopic Ltd','isotopic',
'MRCS','mrcs',
'Macaulay Enterprises Ltd','mel',
'Research Stations','restations',
'Soil Survey \& Land Evaluation
Unit','soilsurvey')||'">
** CODE **
| |
| Peter Fox 2005-03-30, 8:56 pm |
| Following on from apthorburn's message. . .
str_replace
--
PETER FOX Not the same since the porcelain business went down the pan
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
| |
| Malcolm Dew-Jones 2005-03-31, 3:57 am |
| apthorburn (a.thorburn@macaulay.ac.uk) wrote:
: Hi,
: As a bit of a PHP newbie I have a question. On our Intranet we have
: staff listings which we want to move to dynamic pages. As part of the
: SQL in the original pages we have a SQL decode (see below...)
: I have been trying to replicate this approach in PHP but have come
: across no logical solution. I am assuming that there will be a PHP
: based solution?
: Thanks in advance
: Andrew
: ** CODE **
: select '<TR class="'||decode(m.division,
: 'Administration','administration',
: 'Analytical','analytical',
: 'Aramark - Din Rm','aramark',
: 'BioSS','bioss',
: 'Ecological Sciences','ecosci',
: 'Environmental Sciences','envsci',
: 'Fellows/Associates','fellows',
: 'Human Dimensions','humdim',
: 'IFRU','ifru',
: 'Information Technology
: Services','its',
: 'International Feed Resources
: Unit','ifru',
: 'Isotopic Ltd','isotopic',
: 'MRCS','mrcs',
: 'Macaulay Enterprises Ltd','mel',
: 'Research Stations','restations',
: 'Soil Survey \& Land Evaluation
: Unit','soilsurvey')||'">
: ** CODE **
What do mean by "PHP based solution"?
If your PHP script needs to call the Oracle database to get the data then
the quickest/easiest is to just use the SQL as-is. Loop through the query
results and simply echo the results, since they are already formatted.
If you want to do all the logic within PHP (which makes perfectly good
sense to do), then you need to understand what the query is doing, which
is trivial when you know. DECODE is simply an if/then/else function.
if m.division equals 'Administration'
then
the value to use is 'administration'
else
if m.division equals 'Analytical'
then
the value to use is 'analytical'
else
if m.division equals 'Aramark - Din Rm'
then
the value to use is 'aramark'
...etc...
I think it's obvious how to convert the above to something in PHP.
--
This space not for rent.
|
|
|
|
|