Jump to content

[SOLVED] Form w/ PHP Small Problem


Cetanu

Recommended Posts

I have a form that is giving me a tiny problem.

 

I have this:

	
        <label for="rating">I Rate Mythscape...</label>
<select id="rating" name="rating" value="<?php echo $row['rating']; ?>">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option></select>

 

When someone edits their profile, it is supposed to automatically have a value of $row['rating'], which would be what they posted into the DB. However, when they edit their profile it always goes back to having a value of 1....how can I make it so that they do not need to physically change that field every time they edit? ???

Link to comment
https://forums.phpfreaks.com/topic/164807-solved-form-w-php-small-problem/
Share on other sites

<label for="rating">I Rate Mythscape</label>
   <select id="rating" name="rating">
        <option value="1"<?php echo $row['rating'] == 1 ? ' selected="selected"' : ''; ?>>1</option>
        <option value="2"<?php echo $row['rating'] == 2 ? ' selected="selected"' : ''; ?>>2</option>
        <option value="3"<?php echo $row['rating'] == 3 ? ' selected="selected"' : ''; ?>>3</option>
        <option value="4"<?php echo $row['rating'] == 4 ? ' selected="selected"' : ''; ?>>4</option>
        <option value="5"<?php echo $row['rating'] == 5 ? ' selected="selected"' : ''; ?>>5</option>
    </select>

 

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.