edkuan Posted September 27, 2006 Share Posted September 27, 2006 Hi guysim new to php so i hope u guys could help me i've created a table in my sql listing the diners name and rating given :diner name rating (star)Diner A 4 Diner B 6 Diner C 2 Diner D 3what I want to do is displaying it like this in the page diner name rating (star)Diner A **** Diner B ******Diner C ** Diner D ***the astrix here could be a gif of a star , how do I do this so that php would dynamicly create the star im using php , dmxthanks Quote Link to comment https://forums.phpfreaks.com/topic/22204-displaying-data-from-my-sql/ Share on other sites More sharing options...
AbydosGater Posted September 27, 2006 Share Posted September 27, 2006 Well you could use the switch function,www.php.net/switch Its easy ....like"Mysql info here pulling the rating and storing in $rating"switch ($rating) {case 1: echo "This is a * dinner"; break;case 2: echo "This is a ** dinner"; break;case 3: echo "This is a *** dinner"; break;}And so on... You get it? Quote Link to comment https://forums.phpfreaks.com/topic/22204-displaying-data-from-my-sql/#findComment-99652 Share on other sites More sharing options...
wildteen88 Posted September 27, 2006 Share Posted September 27, 2006 Thats a bit of a long winded way of doing it. You can use the [url=http://uk.php.net/manual/en/function.str-repeat.php]str_repeat[/url] function.Example:[code=php:0]$rating = str_repeat("*", $row['dinner_rating']);echo $rating;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22204-displaying-data-from-my-sql/#findComment-99704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.