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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.