sofia403 Posted May 27, 2011 Share Posted May 27, 2011 hi i was wondering how i can display the values for a form that already in db. users submitted a form and then when they log in to their profile they can change the value in a form, but the original value would show the one that they first submitted. makes sense? at the moment its set as blank, how would i display the option value to the one in the db on their profile? thanks <form name="test" method="post"> <select name="ApplicationStatus"> <option value="'">------</option> <option value="In process">In process</option> <option value="Withdrawn">Withdrawn</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/237654-form-values/ Share on other sites More sharing options...
The Little Guy Posted May 27, 2011 Share Posted May 27, 2011 Like so: <?php echo '<form name="test" method="post"> <select name="ApplicationStatus"> <option value="\'">------</option> <option value="In process" '.(($row['column1']=='In process')?'selected="selected"':'').'>In process</option> <option value="Withdrawn" '.(($row['column1']=='Withdrawn')?'selected="selected"':'').'>Withdrawn</option> </select>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/237654-form-values/#findComment-1221216 Share on other sites More sharing options...
sofia403 Posted May 27, 2011 Author Share Posted May 27, 2011 i dont get it i set as in example below but i just get blank as my first option, the value that user submitted in db is not displayed. what am i missing? Quote Link to comment https://forums.phpfreaks.com/topic/237654-form-values/#findComment-1221255 Share on other sites More sharing options...
mikesta707 Posted May 27, 2011 Share Posted May 27, 2011 Can you post the code you are using? It's hard to give a definitive answer without seeing what you are working with Quote Link to comment https://forums.phpfreaks.com/topic/237654-form-values/#findComment-1221265 Share on other sites More sharing options...
sofia403 Posted May 27, 2011 Author Share Posted May 27, 2011 ok here it is <?php include('config.php'); $uname=$_SESSION['username']; if($_SESSION['username']){ $sql="SELECT ApplicationStatus FROM table1 WHERE uname='$uname'"; $result=mysql_query($sql);} echo '<form name="test" method="post"> <select name="ApplicationStatus"> <option value="">------</option> <option value="In process" '.(($row['column1']=='In process')?'selected="selected"':'').'>In process</option> <option value="Withdrawn" '.(($row['column1']=='Withdrawn')?'selected="selected"':'').'>Withdrawn</option> </select>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/237654-form-values/#findComment-1221281 Share on other sites More sharing options...
mikesta707 Posted May 27, 2011 Share Posted May 27, 2011 Simple error. you never define $row. perhaps you mean to stick the following line after your $result=.. line $row = mysql_fetch_array($result); also, I don't know how your table is structured, but are you sure column1 is the correct column? Instead of column1 perhaps it should be ApplicationStatus Quote Link to comment https://forums.phpfreaks.com/topic/237654-form-values/#findComment-1221285 Share on other sites More sharing options...
sofia403 Posted May 27, 2011 Author Share Posted May 27, 2011 hehe thanks! that worked! Quote Link to comment https://forums.phpfreaks.com/topic/237654-form-values/#findComment-1221291 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.