美好的一天,我忙着白色我的评级我从mij数据库发芽,如果我得到1,我希望改变星星,我只想改变1星,我尝试,如果是萌芽,它不会改变一颗星变黄,如果评级大于5,我想要它。我希望5颗星星变黄
我的代码
<?php
defined('_JEXEC') or die;
$userid = $_GET['userid'];
$ster1 = '#ccc';
$ster2 = '#ccc';
$ster3 = '#ccc';
$ster4 = '#ccc';
$ster5 = '#ccc';
?>
<div class="container" data-userid="1"">
<h2 align="center">uw rating</h2>
<br>
<?php if (!empty($this->rating)) : ?>
<?php foreach ($this->rating as $row) : ?>
<span id="beer_list">
<h1 class="text-primary"><?php echo $row->naam; ?></h1>
<p><?php echo $row->tagline; ?></p>
<p><?php echo $row->omschrijving; ?></p>
<label style="text-danger"><?php echo $row->alcohol; ?>%</label>
<p><?php echo (round($row->rating)) ?>★</p>
<p><?php echo ($row->date) ?></p>
<a title="1" beerid="1-1" data-index="1" href="<?php echo \Joomla\CMS\Router\Route::_('index.php?option=com_bierapi&view=beer&userid='.$userid.'&beerid='.$row->beerid.'&rating=1&task=beer.save')?>" data-beerid="1" data-rating="0" class="rating" style="cursor:pointer; color:<?php echo $ster1?>; font-size:16px;">★</a>
<a title="2" beerid="1-2" data-index="2" href="<?php echo \Joomla\CMS\Router\Route::_('index.php?option=com_bierapi&view=beer&userid='.$userid.'&beerid='.$row->beerid.'&rating=2&task=beer.save')?>" data-beerid="1" data-rating="0" class="rating" style="cursor:pointer; color:<?php echo $ster2?>; font-size:16px;">★</a>
<a title="3" beerid="1-3" data-index="3" href="<?php echo \Joomla\CMS\Router\Route::_('index.php?option=com_bierapi&view=beer&userid='.$userid.'&beerid='.$row->beerid.'&rating=3&task=beer.save')?>" data-beerid="1" data-rating="0" class="rating" style="cursor:pointer; color:<?php echo $ster3?>; font-size:16px;">★</a>
<a title="4" beerid="1-4" data-index="4" href="<?php echo \Joomla\CMS\Router\Route::_('index.php?option=com_bierapi&view=beer&userid='.$userid.'&beerid='.$row->beerid.'&rating=4&task=beer.save')?>" data-beerid="1" data-rating="0" class="rating" style="cursor:pointer; color:<?php echo $ster4?>; font-size:16px;">★</a>
<a title="5" beerid="1-5" data-index="5" href="<?php echo \Joomla\CMS\Router\Route::_('index.php?option=com_bierapi&view=beer&userid='.$userid.'&beerid='.$row->beerid.'&rating=5&task=beer.save')?>" data-beerid="1" data-rating="0" class="rating" style="cursor:pointer; color:<?php echo $ster5?>; font-size:16px;">★</a>
</span>
<?php
$rating = (round($row->rating));
if ($rating == 0 ){
$ster1 = '#ccc';
$ster2 = '#ccc';
$ster3 = '#ccc';
$ster4 = '#ccc';
$ster5 = '#ccc';
}elseif ($rating == 1) {
$ster1 = 'yellow';
$ster2 = '#ccc';
$ster3 = '#ccc';
$ster4 = '#ccc';
$ster5 = '#ccc';
}
elseif ($rating == 2) {
$ster1 = 'yellow';
$ster2 = 'yellow';
$ster3 = '#ccc';
$ster4 = '#ccc';
$ster5 = '#ccc';
}elseif ($rating == 3) {
$ster1 = 'yellow';
$ster2 = 'yellow';
$ster3 = 'yellow';
$ster4 = '#ccc';
$ster5 = '#ccc';
}elseif ($rating == 4 ){
$ster1 = 'yellow';
$ster2 = 'yellow';
$ster3 = 'yellow';
$ster4 = 'yellow';
$ster5 = '#ccc';
}elseif ($rating == 5) {
$ster1 = 'yellow';
$ster2 = 'yellow';
$ster3 = 'yellow';
$ster4 = 'yellow';
$ster5 = 'yellow';
}
?>
<?php endforeach; ?>
<?php endif; ?>
<h1> <a href="<?php echo \Joomla\CMS\Router\Route::_('index.php?option=com_bierapi&view=beer&userid='.$userid)?>">naar biertjes </a></h1>
我希望有人能帮助我