I know the title doesn't say a lot.
I'm making a site and I want people to review a book if they want to. This code is on the page, under the product information:
<span class='starRating'>
<input id="rating5" type="radio" name="rating" value="5">
<label for="rating5">5</label>
<input id="rating4" type="radio" name="rating" value="4">
<label for="rating4">4</label>
<input id="rating3" type="radio" name="rating" value="3" checked>
<label for="rating3">3</label>
<input id="rating2" type="radio" name="rating" value="2">
<label for="rating2">2</label>
<input id="rating1" type="radio" name="rating" value="1">
<label for="rating1">1</label>
</span>
</select><br><br>
<button type='submit' onclick='comment.php'>Voeg toe</button>
<?php
$name = $_GET['Naam'];
$comment = $_GET['Comment'];
$rating = $_GET['rating'];
if ($name != '' && $comment != '') {
switch ($rating1) {
case $rating = "1" :
$ratingImg = '<img src=/nl/images1/star-on.svg>';
break;
case $rating = "2" :
$ratingImg = '<img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg>';
break;
case $rating = "3" :
$ratingImg = '<img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg>';
break;
case $rating = "4" :
$rating = '<img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg>';
break;
case $rating = "5" :
$ratingImg = '<img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg><img src=/nl/images1/star-on.svg>';
break;
}
$finalComment = "<?php
echo '<hr><p>Door: $name</p><p>Score: $ratingImg</p><p>$comment</p><br>';?>"
;
I would like to have the number of stars people select as a variable. I have the star system from here. When I send the from the following is in my URL bar: ...?rating=5&...
Can I get this in my $ratingImg
variable? If my question is unclear, please say so.
Door: $name
Score: $ratingImg
$comment
';?>" ;` change to `$finalComment = "
Door: $name
Score: $ratingImg
$comment
"; echo $finalComment;` – Jul 18 '16 at 21:17