Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

swagg

Need basic PHP help, paying with 07 GP

7 posts in this topic

I'm stuck with some PHP work and would need someone to help me. In exchange I'll give 07 GP.

 

I'm stuck with 4, 5, 6 with putting the variable to the CSS class, aswell as the remaining steps after that

...Now we go ahead and change functions.php1. This file will contain only PHP and here we declare the function echoMenu2. The function receives a value $highlight3. First, in the function, we create three values ​​$start, $contacted, $blog and assign them the value ""4. After this, we will look if $highlight is equal to the "Start" so we put $start to class="highlight"5. If $highlight is equal to "Contact" we put $Contact to class="highlight"6. And last if $highlight is equal to "Blog" so we put $blog to class="highlight"After the if statement we want to echo the entire hub tag from mall.htmlWe want to make some changes on the nav-tag so that the function can control which menu items to be highlighted. In each a-tag we want to add the variable that corresponds to the link leads to.How do we change the nav-tag so that each link gets the right variable and if we for example click on the Start link so should the link get the class highlight.Question: How do functions.php out?

This is the CSS highlight class

nav ul li a.highlight{	color: #880045;	background-color: #E869AA;	font-weight: bold;}

I have more PHP to do once this is finished, so I might require more help, and can pay more GP for that

 

If intrested, pm me your skype details and we'll chat there

Edited by swagg

Share this post


Link to post
Share on other sites

Reading it gives me the idea that you already have some code given? If this is not the case then the following should work for point 1 till 6.

<?phpfunction echoMenu( $highlight ) {		//* Create the three values given in 3.	$start = "";	$contacted = "";	$blog = "";		//* Start if statement given in 4.	if ( $highlight == "Start" ){			$start = "class=\"highlight\"";			} 		// Else if statement given in 5.	elseif ( $highlight == "Contact" ) {		$contacted = "class=\"highlight\"";			} 		// Else if statement given in 6.	elseif ( $highlight == "Blog" ) {		$blog = "class=\"highlight\";			}	}?>
Edited by CasJ

Share this post


Link to post
Share on other sites

 

Reading it gives me the idea that you already have some code given? If this is not the case then the following should work for point 1 till 6.

<?phpfunction echoMenu( $highlight ) {		//* Create the three values given in 3.	$start = "";	$contacted = "";	$blog = "";		//* Start if statement given in 4.	if ( $highlight == "Start" ){			$start = "class=\"highlight\"";			} 		// Else if statement given in 5.	elseif ( $highlight == "Contact" ) {		$contacted = "class=\"highlight\"";			} 		// Else if statement given in 6.	elseif ( $highlight == "Blog" ) {		$blog = "class=\"highlight\";			}	}?>

Yes I had some code written :P Thanks alot for helping me assign variables to CSS classes :)

 

This is my code now

<?php function echoMenu($highlight) {	$start = "";	$kontakt = "";	$blogg = "";	if ($highlight == "Start")		$start = "class=\"highlight\"";	if ($highlight == "Kontakt")		$kontakt = "class=\"highlight\"";	if ($highlight == "Blogg")		$blogg = "class=\"highlight\"";	echo "	<nav>		<ul>			<li><a href="index.php">Start</a></li>			<li><a href="index.php?page=blogg">Blogg</a></li>			<li><a href="index.php?page=kontakt">Kontakt</a></li>		</ul>	</nav>	";}?>

Currently getting

Parse error: syntax error, unexpected 'index' (T_STRING), expecting ',' or ';' in C:\xampp\htdocs\Labb2\functions\functions.php on line 15

So I'll have to try fix that now lol

Share this post


Link to post
Share on other sites

You can't use double quotes inside double quotes without putting a backslash in front of them. Here, i finished your code for you:

<?php function echoMenu( $highlight ) {		//* Create the variables	$start = "";	$kontakt = "";	$blogg = "";		//* Set class to $highlight	if ($highlight == "Start") {		$start = "class=\"highlight\"";	}		elseif ($highlight == "Kontakt") {		$kontakt = "class=\"highlight\"";			}		elseif ($highlight == "Blogg") {		$blogg = "class=\"highlight\"";		}		?>		<nav>		<ul>			<li><a href="index.php" <?php echo $start; ?>>Start</a></li>			<li><a href="index.php?page=blogg" <?php echo $blogg; ?>>Blogg</a></li>			<li><a href="index.php?page=kontakt" <?php echo $kontakt; ?>>Kontakt</a></li>		</ul>	</nav>		<?php}
1 person likes this

Share this post


Link to post
Share on other sites

 

You can't use double quotes inside double quotes without putting a backslash in front of them. Here, i finished your code for you:

<?php function echoMenu( $highlight ) {		//* Create the variables	$start = "";	$kontakt = "";	$blogg = "";		//* Set class to $highlight	if ($highlight == "Start") {		$start = "class=\"highlight\"";	}		elseif ($highlight == "Kontakt") {		$kontakt = "class=\"highlight\"";			}		elseif ($highlight == "Blogg") {		$blogg = "class=\"highlight\"";		}		?>		<nav>		<ul>			<li><a href="index.php" <?php echo $start; ?>>Start</a></li>			<li><a href="index.php?page=blogg" <?php echo $blogg; ?>>Blogg</a></li>			<li><a href="index.php?page=kontakt" <?php echo $kontakt; ?>>Kontakt</a></li>		</ul>	</nav>		<?php}

I love you <3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.