Presto-X Posted February 3, 2009 Share Posted February 3, 2009 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 https://forums.phpfreaks.com/topic/143546-is-there-a-more-effecent-way-of-doing-this-maybe-some-type-of-loop/ Share on other sites More sharing options...
DeanWhitehouse Posted February 3, 2009 Share Posted February 3, 2009 A switch statment Link to comment https://forums.phpfreaks.com/topic/143546-is-there-a-more-effecent-way-of-doing-this-maybe-some-type-of-loop/#findComment-753097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.