Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8176973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:23:15+00:00 2026-06-06T23:23:15+00:00

I have this code which echoes me information from the database: <?php include(‘db_connect.php’); mysql_query(SET

  • 0

I have this code which echoes me information from the database:

<?php
  include('db_connect.php');
  mysql_query("SET NAMES UTF8");

$sql =" select * from hostess";
$query = mysql_query($sql);


    while ($row = mysql_fetch_array($query)) { 
    echo "<div id='photo'>"; 
    echo "<div id='picture'>"; 
     echo "<td> <img src=foto/photo1/".$row['photo'] . "></td>";
     echo "</div>"; 
echo "<div id='rating'>"; 
     echo "</div>"; 
     echo "<div id='text'>"; 
     echo '<td><a href="hostess.php?id='.$row['id'].'">'. $row['first_name_en']."&nbsp;". $row['family_name_en']."</a></td>";
    echo "</div>"; 
    echo "</div>"; 
    }
    ?>

I also have a rating system which i want to fetch it to each id. my problem is, how can i assign every rating to each id, i mean each one must have his own rating, they shouldn’t display all in one div like they do now. i need to display the result in the rating div for each one.

The code i use for all results is:

<?php 
// include update.php
include_once 'update.php';
// get all data from tabel
$arr_star = fetchStar();
?>
<?php 
// start looping datas
foreach($arr_star as $star){ ?>
<h2>Star Rater - <?php echo $star['id'];?></h2>
<ul class='star-rating' id="star-rating-<?php echo $star['id'];?>">
<?php /* getRating($id) is to generate current rating */?>
  <li class="current-rating" id="current-rating-<?php echo $star['id'];?>" style="width:<?php echo getRating($star['id'])?>%"><!-- will show current rating --></li>
  <?php 
  /* we need to generate 'id' for star rating.. this 'id' will identify which data to execute  */
  /* we will pass it in ajax later */
  ?>
  <span class="ratelinks" id="<?php echo $star['id'];?>">
  <li><a href="javascript:void(0)" title="1 star out of 5" class="one-star">1</a></li>
    <li><a href="javascript:void(0)" title="1 star and a half out of 5" class="one-star-half">1.5</a></li>
  <li><a href="javascript:void(0)" title="2 stars out of 5" class="two-stars">2</a></li>
    <li><a href="javascript:void(0)" title="2 star and a half out of 5" class="two-star-half">2.5</a></li>
  <li><a href="javascript:void(0)" title="3 stars out of 5" class="three-stars">3</a></li>
    <li><a href="javascript:void(0)" title="3 star and a half out of 5" class="three-star-half">3.5</a></li>
  <li><a href="javascript:void(0)" title="4 stars out of 5" class="four-stars">4</a></li>
    <li><a href="javascript:void(0)" title="4 star and a half out of 5" class="four-star-half">4.5</a></li>
  <li><a href="javascript:void(0)" title="5 stars out of 5" class="five-stars">5</a></li>
  </span>
</ul>
<?php } ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:23:18+00:00Added an answer on June 6, 2026 at 11:23 pm

    try (there maybe typos but hopefully you get the idea)

     switch ($star['id'])
    {
     case 1:
     echo '  <li><a href="javascript:void(0)" title="1 star out of 5" class="one-star">1</a></li> 
        <li><a href="javascript:void(0)" title="1 star and a half out of 5" class="one-star-half">1.5</a></li>';
     break;
     case 2: 
     echo '  <li><a href="javascript:void(0)" title="2 stars out of 5" class="two-stars">2</a></li> 
        <li><a href="javascript:void(0)" title="2 star and a half out of 5" class="two-star-half">2.5</a></li> ']
     break;
     case 3: 
      echo '  <li><a href="javascript:void(0)" title="3 stars out of 5" class="three-stars">3</a></li> 
        <li><a href="javascript:void(0)" title="3 star and a half out of 5" class="three-star-half">3.5</a></li> '; 
      break;
     case 4:
     echo '  <li><a href="javascript:void(0)" title="4 stars out of 5" class="four-stars">4</a></li> 
        <li><a href="javascript:void(0)" title="4 star and a half out of 5" class="four-star-half">4.5</a></li> ';
      break;
     case 5:
      echo '  <li><a href="javascript:void(0)" title="5 stars out of 5" class="five-stars">5</a></li> ';
     break;
     default :  
      echo 'No vote';
      break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code which will include template.php file from inside each of these
I have this code which does the trick: #include <stdio.h> int main() { int
I have this code (which is way simplified from the real code): public interface
I have this code which is passed to Paypal checkout: <?php foreach ($paypalBasket as
I have this code which export data from GridView to csv. It works with
I have this code which retrieves some data from a sql query and place
I have this code which I need to set a unique title : var
I have this code which depends on this javascript from dynamic drive: http://dynamicdrive.com/dynamicindex16/formdependency.htm Its
I have this code, which uses ob_start php function. Which basically puts the echoed
I have this code which adds a x number of views to a Multiview

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.