I was wondering if someone could help me with a PHP rating script dilemma. I am using DRBRatings script and would like to change the ratings drop down menu to radio buttons. I have tried several times to figure it out myself but end up with nothing more than a headache!

I believe I need to change the code in the following lines of the ratings.php.

function show_rate_form($id) { 
   global $RATE_THIS_STRING; 
   global $MAX_STARS; 
   global $SUBMIT_BUTTON_STRING; 
   global $RATING_LABELS; 
   global $RATING_LIST_DEFAULT_LABEL; 
   global $RATINGS_URL; 
   global $RATING_ID_PARAM_NAME; 
   global $RATING_PARAM_NAME; 

   echo("\t<form class=\"rateIt\" method=\"post\" action=\"" . $RATINGS_URL . "rate.php\">\r\n"); 
   echo("\t\t" . htmlspecialchars($RATE_THIS_STRING) . "\r\n"); 
   echo("\t\t<select name=\"" . htmlspecialchars($RATING_PARAM_NAME) . "\">\r\n"); 
   echo("\t\t\t<option value=\"\">" . htmlspecialchars($RATING_LIST_DEFAULT_LABEL) . "</option>\r\n"); 
   for($i = 1; $i <= $MAX_STARS; $i++) { 
      echo("\t\t\t<option value=\"" . $i . "\">" . $i); 
      if(!empty($RATING_LABELS) && isset($RATING_LABELS[$i])) { 
         echo(" - " . htmlspecialchars($RATING_LABELS[$i])); 
      } 
      echo("</option>\r\n"); 
   } 
   echo("\t\t</select>\r\n"); 
   echo("\t\t<input type=\"hidden\" name=\"" . htmlspecialchars($RATING_ID_PARAM_NAME) . "\" value=\"" . htmlspecialchars($id) . "\" />\r\n"); 
   echo("\t\t<input type=\"submit\" value=\"" . htmlspecialchars($SUBMIT_BUTTON_STRING) . "\" class=\"submit\" />\r\n"); 
   echo("\t</form>\r\n"); 

}

Any help would be greatly appreciated as I am fairly new to PHP and this is a big problem for my website development.

Cheers!

    Maybe try this:

    function show_rate_form($id) { 
       global $RATE_THIS_STRING; 
       global $MAX_STARS; 
       global $SUBMIT_BUTTON_STRING; 
       global $RATING_LABELS; 
       global $RATING_LIST_DEFAULT_LABEL; 
       global $RATINGS_URL; 
       global $RATING_ID_PARAM_NAME; 
       global $RATING_PARAM_NAME; 
    
       echo("\t<form class=\"rateIt\" method=\"post\" action=\"" . $RATINGS_URL . "rate.php\">\r\n"); 
       echo("\t\t" . htmlspecialchars($RATE_THIS_STRING) . "\r\n"); 
       $name = htmlspecialchars($RATING_PARAM_NAME);
       for($i = 1; $i <= $MAX_STARS; $i++) { 
          echo("\t\t\t<input type=\"radio\" name=\"" . $name . "\" value=\"" . $i . "\">" . $i); 
          if(!empty($RATING_LABELS) && isset($RATING_LABELS[$i])) { 
             echo(" - " . htmlspecialchars($RATING_LABELS[$i])); 
          } 
          echo("\r\n"); 
       } 
       echo("\t\t<input type=\"hidden\" name=\"" . htmlspecialchars($RATING_ID_PARAM_NAME) . "\" value=\"" . htmlspecialchars($id) . "\" />\r\n"); 
       echo("\t\t<input type=\"submit\" value=\"" . htmlspecialchars($SUBMIT_BUTTON_STRING) . "\" class=\"submit\" />\r\n"); 
       echo("\t</form>\r\n"); 
    
    }

      Thanks heaps mate, that did the trick! I was putting type=\"radio\" all over the shop, but without the $name function.

      Thankyou for the quick response.

        Write a Reply...