This topic is locked

Changing table display

2/22/2010 1:33:03 PM
PHPRunner General questions
C
cynic author

Hi,
I'm currently using the trial version of PHPRunner and I'm also pretty new at using MSSQL databases. I've run into a bit of a road block and I'm sure there's a really simple solution but I can't for the life of me figure it out.
Basically, I have a field which is called order_status. In the database, this is stored as a value from 1 to 5. What I want to do is output this on the list page as the actual meaning of the status code.
so
If ($table['order_Status']=='1') {echo"Meaning of Status 1"};

If ($table['order_Status']=='2') {echo"Meaning of Status 2"};

If ($table['order_Status']=='3') {echo"Meaning of Status 3"};

If ($table['order_Status']=='4') {echo"Meaning of Status 4"};

If ($table['order_Status']=='5') {echo"Meaning of Status 5"};
I know the syntax is incorrect but being a novice, I can't figure out how to get this working at all. I've read through a lot of the documentation but can't figure out if this should be done as an event or as a new field or what...?
Thanks in advance for any help.

A
alang 2/22/2010

One of the easiest ways to do this is to create a new table in your database with two fields:

  • first field (index or key) is the StatusID - number 1 to 5
  • second field is StatusMeaning - text ie "Meaning of Status 1"
    In PHPR, go to the Visual editor, double click on the status field, click on Edit as, and select lookup wizard. Specify lookup table, select your new table created above with link field as the StatusID and the display field as StatusMeaning.
    No coding required!

C
cynic author 2/22/2010



One of the easiest ways to do this is to create a new table in your database with two fields:

  • first field (index or key) is the StatusID - number 1 to 5
  • second field is StatusMeaning - text ie "Meaning of Status 1"
    In PHPR, go to the Visual editor, double click on the status field, click on Edit as, and select lookup wizard. Specify lookup table, select your new table created above with link field as the StatusID and the display field as StatusMeaning.
    No coding required!


That was a consideration however, we're populating the numerous databases from an exe that's hardcoded to create a database, write to the database and then flush the aforementioned database every 30 days. With the several hundred individual databases and software users, it's not going to be possible to recode the exe and get all of the users upgraded before we can go live with any kind of database reporting tool - the cost involved would be astronomical.
Thanks for the suggestion though, I'll keep trying various methods within PHPRunner and hopefully stumble upon some kind of solution. The annoying thing is that this is the only stumbling block I've come across so far in my admittedly "not very complex" reporting tool.

Sergey Kornilov admin 2/23/2010

You can set 'View as' type of this field to 'Custom' and use the following code:



if ($value=='1') $value="Meaning of Status 1";

if ($value=='2') $value="Meaning of Status 2";

...
C
cynic author 2/25/2010



You can set 'View as' type of this field to 'Custom' and use the following code:



if ($value=='1') $value="Meaning of Status 1";

if ($value=='2') $value="Meaning of Status 2";

...



Thank you very much, that's a perfect solution! I was close, but no cigar!