redarrow Posted September 17, 2006 Share Posted September 17, 2006 advance thank you.The radio buttion has a yes or no how do you display it back as a yes or no to edit with the users selected choose from the database cheers.example of radio buttion.[code]<form method="POST" action=""><br>do you like redarrow<br><input type="radio" name="like" value="yes" checked>yes<input type="radio" name="like" value="no" >no<br><br><input type="submit" name="submit" value="ansaw please"></form>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 17, 2006 Share Posted September 17, 2006 [code]<?phpif (isset($_POST['submit'])) { $likeme = $_POST['like']; echo $likeme;// do whatever else you want ...}?><form method="POST" action="">... more form code[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 17, 2006 Share Posted September 17, 2006 You need to compare the db field value with each of the button values. The one that matches is set as 'checked'.[code]<?php$dbLike = 'yes'; // <---- value from database?><form method="POST" action=""><br>do you like redarrow<br><input type="radio" name="like" value="yes" <?php echo $dbLike=='yes' ? 'checked' : '' ?> >yes<input type="radio" name="like" value="no" <?php echo $dbLike=='no' ? 'checked' : '' ?> >no<br><br><input type="submit" name="submit" value="answer please"></form>[/code]If you have several possible values then it's easier to use an array and test each value in a loop.[code]<?php$dbLike = 3; // <---- value from database?><form method="POST" action=""><br>do you like redarrow<br><?php $likes = array ( 0 => "Who's he?", 1 => "Really like the guy", 2 => "He's OK", 3 => "Neutral feelings", 4 => "Not a lot", 5 => "Hate the guy" ); foreach ($likes as $val => $text) { $chk = $dbLike==$val ? 'checked' : ''; echo "<input type='radio' name='like' value='$val' $chk> $text<br>"; }?><br><input type="submit" name="submit" value="answer please"></form>[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 17, 2006 Author Share Posted September 17, 2006 Barand thank you so much another for the white board whale perfect and cheers andy grate stuff. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 17, 2006 Share Posted September 17, 2006 How big is this whiteboard? Must be getting pretty full ;D Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 17, 2006 Author Share Posted September 17, 2006 gone throw 200 markers on the stats code lol. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.