Jump to content

populating radio button with $_SESSION data


Recommended Posts

The below should choose the radio button that is set by the $_SESSION variable or default to 3. However, it's defaulting to 1.

 

$content.='
<p class="form_item"><label>Product Rating:</label><br />
<div class="rating_radio"><input type="radio" name="review_product_rating" value="1"';
if(isset($review_product_rating) && $review_product_rating=="1"){$content.='checked';}
$content.=' /> <br />1</div>
<div class="rating_radio"><input type="radio" name="review_product_rating" value="2"';
if(isset($review_product_rating) && $review_product_rating=="2"){$content.='checked';}
$content.=' /> <br />2</div>
<div class="rating_radio"><input type="radio" name="review_product_rating" value="3"';
if(isset($review_product_rating) && $review_product_rating=="3" || !isset($review_product_rating)){$content.='checked';}
$content.=' /> <br />3</div>
<div class="rating_radio"><input type="radio" name="review_product_rating" value="4"';
if(isset($review_product_rating) && $review_product_rating=="4"){$content.='checked';}
$content.=' /> <br />4</div>
<div class="rating_radio"><input type="radio" name="review_product_rating" value="5"';
if(isset($review_product_rating) && $review_product_rating=="5"){$content.='checked';}
$content.=' /> <br />5</div>
<div class="worst">(Worst)</div><div class="best">(Best)</div>
</p>

 

I'm figuring it's because it's multiple if statement (with no elseif) so it's evaluating the first if and being set to true. I tried changing everything else after the first one to elseif, and it's throwing an unexpected T_ELSEIF error.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.