Jump to content

Is there a more effecent way of doing this maybe some type of loop?


Presto-X

Recommended Posts

Hello everyone,

 

I'm working on a page that submits information to the database and the form is built in to 3 diffrent pages I created a light gray heading at the top of each page "Step 1 > Step 2 > Step 3", if you are on step 2 then it changes it's color to blue, very simple right?

 

This is the code that I have been using is there a more efficient way of doing this maybe some type of loop?

 

<style type="text/css">
.steps{
color:#e4e4e4;
font-size:24px;
font-weight:bold;
}
.step_active{
color:#3399ff;
}
.step_visited{
color:#e4e4e4;
}
.step_unvisited{
color:#999999;
}
</style>

 

<?PHP
  if($_GET['step'] <= "1"){$step1 = ' class="step_unvisited"';}
  if($_GET['step'] == "1"){$step1 = ' class="step_active"';}
  if($_GET['step'] > "1"){$step1 = ' class="step_visited"';}
  if($_GET['step'] <= "1"){$step1_5 = ' class="step_unvisited"';}else{$step1_5 = ' class="step_visited"';}
  if($_GET['step'] < "2"){$step2 = ' class="step_unvisited"';}
  if($_GET['step'] == "2"){$step2 = ' class="step_active"';}
  if($_GET['step'] > "2"){$step2 = ' class="step_visited"';}
  if($_GET['step'] > "2"){$step2_5 = ' class="step_visited"';}else{$step2_5 = ' class="step_unvisited"';}
  if($_GET['step'] < "3"){$step3 = ' class="step_unvisited"';}
  if($_GET['step'] == "3"){$step3 = ' class="step_active"';}
  if($_GET['step'] > "3"){$step3 = ' class="step_visited"';}
?>
<div class="steps">
  <span<?PHP echo $step1; ?>>Step 1</span>
  <span<?PHP echo $step1_5; ?>>»</span>
  <span<?PHP echo $step2; ?>>Step 2</span>
  <span<?PHP echo $step2_5; ?>>»</span>
  <span<?PHP echo $step3; ?>>Step 3</span>
</div>

 

I would enjoy hearing fellow phpfreak members ideas and opinions... So what do you think?

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.