I'm trying to limit the amount of results that show in my foreach, I've got this so far:
<?php $facilitiescounter = 0; ?>
<?php foreach ($facilities as $data) {
if (++$facilitiescounter == 7) break;
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>'; }?>
<a class="read-more-show hide" href="#">Show More</a> <span class="read-more-content">Show all other results from array <a class="read-more-hide hide" href="#">Show Less</a></span>
I have managed to limit it to the first 6 results, is it possible to do another foreach to get all the other results excluding the first six?
Or is there a better way of doing this?
Thanks!
A simple for loop is more appropriate in this case, as we can determine begin and end easily
To the first six results:
for($i = 0, $t = min(6, count($facilities)); $i < $t; ++$i)
{
$facilities[$i]->Name
....
The other ones:
for($i = 6, $t = count($facilities); $i < $t; ++$i)
{
$facilities[$i]->Name
....
Note: added minimum verification in case $facilities has less than 6 elements. Thanks to #lanis
You can use array_slice() http://php.net/manual/fr/function.array-slice.php
$datas = array_slice($facilities, 0, 6); // First 6 items
foreach($datas as $data) {
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}
$datas = array_slice($facilities, 6); // Items after 6
foreach($datas as $data) {
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}
Yes, you can do it as a better way. Just get your $facilities array in some temporary array which is called $temp and then whenever your foreach loop is executing just remove that element from the $temp array. After that you just replace $facilities array with the $temp.
<?php $facilitiescounter = 0; ?>
<?php foreach ($facilities as $data) {
if (++$facilitiescounter <= 7) break;
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>'; }?>
<a class="read-more-show hide" href="#">Show More</a> <span class="read-more-content">Show all other results from array <a class="read-more-hide hide" href="#">Show Less</a></span>
i have changed the if condition only. it will give you proper result. try it!
Related
This question already has answers here:
Displaying star rating with Font Awesome icons
(4 answers)
Laravel - Star rating - Optimization?
(5 answers)
Closed last month.
I have a script which reads an array from a text file and grabs each line and produces star rating images based on number in array. The script is kind of big and was wondering if there was a better way of doing this.
<?php if ($row[2] == '5') { ?>
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i>
<?php } elseif ($row[2] == '4.5') { ?>
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-half-o"></i>
<?php } elseif ($row[2] == '4') { ?>
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-o"></i>
<?php } elseif ($row[2] == '3.5') { ?>
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-half-o"></i><i class="fa fa-star-o"></i>
<?php } elseif ($row[2] == '3') { ?>
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i>
<?php } elseif ($row[2] == '2.5') { ?>
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-half-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i>
<?php } elseif ($row[2] == '2') { ?>
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i>
<?php } elseif ($row[2] == '1.5') { ?>
<i class="fa fa-star"></i><i class="fa fa-star-half-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i>
<?php } elseif ($row[2] == '1') { ?>
<i class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i>
<?php } elseif ($row[2] == '.5') { ?>
<i class="fa fa-star-half-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i>
<?php } elseif ($row[2] == '0') { ?>
<i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i>
<?php } ?>
Yes, better ways... A loop will help, maybe something like this (PHP demo at tio.run).
function star_printer($num)
{
$star_class = [
'blank' => 'far fa-star',
'half' => 'fas fa-star-half',
'full' => 'fas fa-star'];
$star_html = '<i class="%s"></i>';
$star_str = "";
for($i=1; $i<=5; $i++)
{
$is_half = $i==ceil($num) && ceil($num)!=$num;
$star = $is_half ? "half" : ($i>$num ? "blank" : "full");
$star_str .= sprintf($star_html, $star_class[$star]);
}
return $star_str;
}
echo star_printer(3.5);
You can work off this function (doesn't include the half stars, shows you how to do the full star rating - I just noticed you run halfs as well);
function getStars($rating){
$stars = "";
$x = 0;
while($x < $rating) {
$stars = $stars.'<i class="fa fa-star"></i>';
$x++;
}
return $stars;
}
echo getStars(3);
in your case -
echo getStars($row[2]);
You can tweak this that if the number contains a decimal you can append to the string '' for example; you get the gist :P
-------------- Edit
Tweaked it and added the half star rating :)
function getStars($rating){
$stars = "";
$x = 1;
while($x <= $rating) {
$stars = $stars.'<i class="fa fa-star"></i>';
$x++;
}
if (strpos($rating, '.') !== false) {
$stars = $stars . '<i class="fa fa-star-half">';
}
return $stars;
}
echo getStars(3.5);
function getStar($rating) {
$wholeStar = "<i class="fa fa-star"></i>";
$halfStar = "<i class="fa fa-star-half-o"></i>";
// round the rating for whole stars
$roundedRating = round($rating);
// Add the whole stars using str_repeat
$starString = str_repeat($wholeStar, round($rating));
// Add the half star if the rating is bigger than it's rounded value
if ($roundedRating < $rating) {
$starString .= $halfStar;
}
return $starString
}
echo getStar($row[2]);
I'm new to PHP and I'm having some trouble with a sort by with a dropdown.
I have a page of movies already sorted by genre and within that page I want to be able to sort by title, rating and year and I don't know how to do it.
In the index page I was able to sort the movies easily because they weren't already sorted by genre, so I just had to put ORDER BY something in the query and it returned what I wanted.
The problem now is that I have to check which genre is chosen at that moment and associate it with what I choose from the dropdown list and I dont know how to do it...
I don't know if this is explicit enough, but if you have any doubt please ask me...
I have the following code which I copied from an existing question here:
<form class="sortby_form" action="">
<div class="sortby" method="POST">
<select name="sort_by" class="drop-box">
<option selected hidden <?php if(isset($_POST['sort_by']) && $_POST['sort_by'] == 'option') echo 'selected="selected"'; ?> value="option">Sort by</option>
<option <?php if(isset($_POST['sort_by']) && $_POST['sort_by'] == 'title') echo 'selected="selected"'; ?> value="title">Title</option>
<option <?php if(isset($_POST['sort_by']) && $_POST['sort_by'] == 'year') echo 'selected="selected"'; ?> value="year">Year</option>
<option <?php if(isset($_POST['sort_by']) && $_POST['sort_by'] == 'rating') echo 'selected="selected"'; ?> value="rating">Rating</option>
</select>
</div>
<form>
This is the code that I have which returns the movies ordered by genre:
<?php
if (isset($_REQUEST["g"])) {
$g = $_REQUEST["g"];
} else {
$g=0;}
$q_sortg = "SELECT id_movie, title, image, plot, rating, id_genre, genre
FROM movie_genre AS mg
INNER JOIN movie AS m ON mg.movie_id_movie = m.id_movie
INNER JOIN genre AS g ON mg.genre_id_genre = g.id_genre
WHERE id_genre = '$g'";
$r_sortg = mysqli_query($dbc, $q_sortg);
$i=0;
echo '<div class="row row-eq-height">';
while ($row_sortg = mysqli_fetch_array($r_sortg)) {
if($row_sortg['id_genre'] == $g) {
echo '<div class="col-sm-3 col-lg-3 col-md-3 column">';
echo '<div class="thumbnail movie-box">';
echo '<img src="data:image/jpg;base64,'.base64_encode($row_sortg['image']).'" width="250px" height="300px" />';
echo '<div class="caption">';
echo "<h4 class=\"title-subs\"><a href='movies_info.php?m=".$row_sortg['id_movie']."'>".$row_sortg['title']."</a></h4>";
echo "<p class=\"title-subs\">".$row_sortg['plot']."</p>";
echo "</div>";
echo '<div class="ratings align-center">';
echo '<p>';
$ratings = $row_sortg['rating'];
$rates = array('$row_sortg' => $ratings);
foreach ($rates as $r => $value) {
if($value <= 1.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
}
else if($value <= 2.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
}
else if($value <= 3.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
}
else if($value <= 4.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
}
else if($value <= 5.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
}
else if($value <= 6.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
}
else if($value <= 7.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
}
else if($value <= 8.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star-o" aria-hidden="true"></i>';
}
else if($value <= 9.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
}
else if($value <= 10.0){
echo '<p>'.$value.'</p>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
echo '<i class="fa fa-star" aria-hidden="true"></i>';
}
}//fecha o foreach
echo '</p>';
echo '</div>';
echo "</div>";
echo "</div>";
$i++;
if ($i%4 == 0){
echo '</div><div class="row row-eq-height">';
} //fecha o if
} //fecha o While
}
?>
Here's the link to the current website:
http://www.zoomlab.pt/2016-web2/pub/grupo4/index.php
In the first page that appears its possible to sort by with no problem.
The problem is when you click in one of the genres in the left column. They appear ordered by genre and then I cant get the sort by to work...
I was initially trying to use bootstrap dropdown but it uses <li><a> instead of <select> and <option>, so I didn't know if it was possible.
Thanks in advance for any help possible.
It looks like you just need to resubmit the form once a user changes the sort option? If so, you'd need to use JavaScript to add an onchange event on your <select>, which will resubmit the form:
<script>
window.addEventListener('DOMContentLoaded', function () {
var form = document.querySelector('form.sortby_form'),
select = form.querySelector('select[name="sort_by"]');
select.addEventListener('change', function () {
form.submit();
});
});
</script>
Also, if this is for a production web site, you really should not use raw user input as part of a SQL query. See: http://php.net/manual/en/mysqli-stmt.bind-param.php
So I currently have this, so if $iDontWant matches something in the array from $data->Name, it removes the whole line. Using the same method how could I do the same but with multiple $iDontWant? So say another $iDontWant2, and this also remove from the foreach? Every way I have tried seems to break things!
$iDontWant="bla"
foreach($datas as $data) {
if($data->Name == $iDontWant) continue;
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}; ?>
Any help would be great, thanks!
Declare $iDontWant as an array and use in_array():
$iDontWant = ["one", "two"];
foreach($datas as $data) {
if(in_array($data->Name, $iDontWant)) {
continue;
}
}
As an alternative to only loop the ones you want, just take the difference and loop that:
$iDontWant = ["one", "two"];
foreach(array_diff($datas, $iDontWant) as $data) {
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}
I'm using eKomi and want to pull in reviews to my website. I've managed to get this working but there's a slight problem. Currently every single review is getting added, and in reverse order.
You'll see from the code below that I am using fgetcsv.
Is it possible to limit to the 12 latest reviews? and then order them from newest to oldest?
Here's the code I've put together.
<div class="row">
<div class="row__colspaced">
<?php
$row = 1;
if (($handle = fopen("http://api.ekomi.de/get_feedback.php?interface_id=66630&interface_pw=f2d097e83db1880e85e2f77aa&range=3m&type=csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
echo "<div class='colspan12-4 colspan6-3 as-grid with-gutters'><div class='content-module--review-list__item item' data-mh='review-item'>";
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
if($c == 0){
echo gmdate('Y-m-d H:i:s',$data[$c]);
}
else if($c == 2){
if($data[$c] == 1){
echo '<div class="fa-star-rating">
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
</div>';
}
if($data[$c] == 2){
echo '<div class="fa-star-rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
</div>';
}
if($data[$c] == 3){
echo '<div class="fa-star-rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
</div>';
}
if($data[$c] == 4){
echo '<div class="fa-star-rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
</div>';
}
if($data[$c] == 5){
echo '<div class="fa-star-rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
</div>';
}
}
else {
echo '<div class="inner-item item'.$c.'">' . $data[$c] . "</div>";
}
}
echo "</div></div>";
}
fclose($handle);
}
?>
</div>
</div>
I'm pulling data from an array, but show certain parts of the data above others, I've managed to choose certain text to go above others. Is there anyway to hide text from the array if it matches the piece of text I give it, using the below code?
<?php $datas = array_slice($facilities, 0, $leftoshownumber); // First 6 items
foreach($datas as $data) {
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}; ?>
This is the full code for this section
<div class="checkmark-outer">
<?php $startnumber = 6; $parkingnumber = 0; $gardennumber = 0; $dishwashernumber = 0; $summerrentnumber = 0; ?>
<?php if (strpos($facilitiesstring, 'Reduced Summer') !== false) { $summerrentnumber = 1; echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">Reduced Summer Rent Available</div></div>';}; ?>
<?php if (strpos($facilitiesstring, 'Parking') !== false) {$parkingnumber = 1; echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">Parking Available</div></div>';}; ?>
<?php if (strpos($facilitiesstring, 'Garden') !== false) {$gardennumber = 1; echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">Garden</div></div>';}; ?>
<?php if (strpos($facilitiesstring, 'Dishwasher') !== false) {$dishwashernumber = 1; echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">Dishwasher</div></div>';}; ?>
<?php $totalfixednumber = $parkingnumber + $gardennumber + $dishwashernumber + $summerrentnumber; $leftoshownumber = $startnumber - $totalfixednumber;?>
<?php $datas = array_slice($facilities, 0, $leftoshownumber); // First 6 items
foreach($datas as $data) {
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}; ?>
<div class="clearfix"></div>
<div class="read-more-show hide">Show More</div><div class="read-more-content"><?php $datas = array_slice($facilities, 6); // Items after 6
foreach($datas as $data) {
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}; ?><div class="clearfix"></div><div class="read-more-hide hide">Show Less</div></span></div>
</div>
Any help would be great!
Do you mean you don't want to print the whole line, when the name matches a given variable?
Then I would do:
$iDontWant="bla"
foreach($datas as $data) {
if($data->Name == $iDontWant) continue;
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}; ?>
EDIT:
if you want multiple names not to show you could do:
$iDontWant1="bla1"
$iDontWant2="bla2"
$iDontWant3="bla3"
foreach($datas as $data) {
if($data->Name == $iDontWant1 || $data->Name == $iDontWant2 || $data->Name == $iDontWant3) continue;
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}; ?>
('||' stands for 'or' by the way)
So basically what you are doing is saying, when
either the name is the same as the content of $iDontWant1, which is "bla1"
or the name is the same as $iDontWant2, which is "bla2"
or the name is the same as the content of $iDontWant3, which is "bla3"
do continue (don't print this part).
However if you know what "bla1", "bla2" ... are, it is easier to just do
foreach($datas as $data) {
if($data->Name == "bla1" || $data->Name == "bla2" || $data->Name == "bla3") continue;
echo '<div class="checkmark-33"><div class="fa-stack fa-1x checkmark-icon"><i class="fa fa-circle fa-stack-2x icon-background"></i><i class="fa fa-check fa-stack-1x icon-text"></i></div><div class="checkmark-inner">'. $data->Name .'</div></div>';
}; ?>
You will just compare to the String directly instead of comparing to the variable containing the string.
I hope I can help you with this.
But if you'd like to do more stuff with PHP I'd recommend a tutorial like https://secure.php.net/manual/en/tutorial.php to really understand the concepts behind this language