Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics Daily Exercise Program Conditionals

Vince Roszak
Vince Roszak
588 Points

Code Challenge

Having trouble on how i would do this

index.php
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment

if ( ) {

} else {

}

?>

2 Answers

Julian Gutierrez
Julian Gutierrez
19,201 Points

That's a good start, your condition now needs to test if the student's gpa is equal to 4.0. If it's equal echo out the requested "Honor Roll" string. If it isn't equal, echo out the "has GPA" string. Do this twice, once for each student.

Vince Roszak
Vince Roszak
588 Points

Im still stuck on it

Vince Roszak
Vince Roszak
588 Points

this is what i have so far

<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment

if ($studentOneGPA == 4.0) {
echo " Dave made the Honor Roll";
} else {
echo "Dave has a GPA of $studentOneGPA"
}

if ($studentTwoGPA == 4.0) {
  echo "Treasure made the Honor Roll"
} else {
"Treasure has a GPA of $studentTwoGPA"
}

?>

Vince - try echoing out

"$studentOneName made the Honor Roll";

like that every time the student's name is supposed to be mentioned. Use the variable instead of a String Literal that has the variable's value.