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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.