php - Need a function for a dynamic table -


i'm learning functions. i've explored couple tutorials, can't yet visualize how immediate problem can translated function. in addition, got error message when put sample function inside while loop; not being able redeclare it.

so wondered if show me how convert following function. note code, including table cell, inside while loop. have somehow remove while loop before put function in it?

switch($latin) {  case 'aix sponsa':  case 'gavia immer':  $star_rating = '<sup><span style="color: #f00;"><b>+</b></span></sup>';  break;  default:  break; }  <td class="symbol"><a href="$gz_url/life/'.$latinl.'" title="'.$symbol.'  ('.$latin.')">'.$row['symbol'].'</a>'.$star_rating.''.$desigast.'</td> 

define function outside loop:

function get_star_rating($latin) {     $star_rating = '';     switch ($latin) {         ...     }     return $star_rating; } 

inside loop, do:

echo <td class="symbol"><a href="$gz_url/life/'.$latinl.'" title="'.$symbol.'  ('.$latin.')">'.$row['symbol'].'</a>'.get_star_rating($latin).$desigast.'</td> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -