function stars($star_rating){ $array = explode('.',$star_rating); $stars = ''; if(preg_match('@[0-4]@',$array[0])){ for($i=0;$i<$array[0];$i++){ $stars .= '*'; } } if(count($array)==2){ $stars .= '1/2'; } if(preg_match('@[A-Z]@',$star_rating)){ $stars .= $star_rating; } if($star_rating=='0'){ $stars .= '(no stars)'; } $stars = ''.$stars.''; return $stars; } function _e($str){ return htmlspecialchars($str); } require_once('mysql.php'); $db = new MySQL; $db->connect(); $result = $db->select("SELECT * FROM master_list ORDER BY year,title ASC"); ?> while($movie = $db->get_row($result)): ?> if($movie['year']!=$last_year): ?>
= $movie['year'] ?>
endif; $last_year = $movie['year']; ?>
= _e($movie['title']) ?> (= _e($movie['directors']) ?>) = stars($movie['star_rating']) ?>
endwhile; ?>