Jump to content

couple of different iterations i need to merge, i think


glennn.php

Recommended Posts

ok, i'm having trouble wrapping my mind around this little hurdle:

 

having this:

 

$option_1 = $row['option_1']; 
$option_2 = $row['option_2']; 
[...]
$option_78 = $row['option_78']; 

 

where ANY of $option_x would contain:

 

switch ($options) {
  case "option_19000" : $option = "aaa";
  break;
  case "option_19001" : $option = "bbb";
  break;
[...]
  case "[b]option_19176[/b]" : $option = "176xxx";
  break;
}

 

and i have this, which gets me what i want from the database:

 

for ($i=1;$i<76;++$i) {

  if (${'option_'.$i} != '') $pagetext .= ${'option_'.$i} . "<br>\n";

}

 

i can't figure out how to then apply my switch when $pagetext contains, say "option_19001"...

 

i'd appreciate any help someone can offer.

 

GN

 

agreed, i'm sure i've made it more complicated than needed - my client supplied me with spreadsheets of these options ...

 

let me try to draw up a little schema:

 

FIELDS          |      option_1          |      option_2          |      option_3          |

VALUES          |    option_19015    |    option_19001    |    option_19065    |

VALUES          |    option_19022    |                              |    option_19043    |

heck, i'll write it in english/sql...

 

select * from table where id = 1;

 

i'll get o _1 thru o_76 THAT CONTAIN A VALUE

 

if ($o_1 == "option_19001") {         

pagetext .= "aaa';

} elseif ($o_1 == "option_19002") {  //  $option_19001 thru $option_19176

pagetext .= "bbb";

 

}

 

 

if ($o_2 == "option_19001") {

pagetext .= "aaa';

} elseif ($o_2 == "option_19002") {  //  $option_19001 thru $option_19176

pagetext .= "bbb";

}

 

 

  //  $o_1 thru $o_76

 

i'm very sorry. i don't know why this is hard to understand...

 

i have 76 variables i retrieve from the database:

 

$o_1 = $row['option_1'];

$o_76 = $row['option_76'];

 

each variable in turn contains 1 of 175 values each of which refer to another (longer) value. my client did this in a spreadsheet.

 

option_19001 thru option_19176

 

so for each $o_xx (x 76) I have "option_xxxxx" which represents a value contained in a long switch...

 

am i being daft?

$if ($o_1 == "option_19001") {         

$pagetext .= "aaa';

} elseif ($o_1 == "option_19002") {  //  $option_19001 thru $option_19176

$pagetext .= "bbb";

 

etc...

 

}

 

 

if ($o_2 == "option_19001") {

$pagetext .= "aaa';

} elseif ($o_2 == "option_19002") {  //  $option_19001 thru $option_19176

$pagetext .= "bbb";

 

etc...

 

 

}

 

 

  //  $o_1 thru $o_76

 

 

 

echo $pagetext;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.