yddib Posted September 4, 2008 Share Posted September 4, 2008 Hi, I have successfully taken code from my database into a form so people can update it. However my form has 2 text areas and 2 drop down menus. The info from these do not come out of the database for me. Is there different code I need to get this information successfully? This is an example of one of the drop down menus <select tabindex="6" name="birthd" id="birthd" value="<?php echo $row['birthd'] ?>"class="date"> <option value="0" id="day_option">Day</option> <option value="1" name="1">1</option> <option value="2" name="2">2</option> <option value="3" name="3">3</option> <option value="4" name="4">4</option> <option value="5" name="5">5</option> <option value="6" name="6">6</option> <option value="7" name="7">7</option> <option value="8" name="8">8</option> <option value="9" name="9">9</option> <option value="10" name="10">10</option> <option value="11"name="11" >11</option> <option value="12" name="12">12</option> <option value="13" name="13">13</option> <option value="14" name="14">14</option> <option value="15" name="15">15</option> <option value="16" name="16">16</option> <option value="17" name="17">17</option> <option value="18" name="18" >18</option> <option value="19" name="19">19</option> <option value="20" name="20">20</option> <option value="21" name="21" >21</option> <option value="22" name="22" >22</option> <option value="23" name="23">23</option> <option value="24" name="24">24</option> <option value="25" name="25">25</option> <option value="26" name="26" >26</option> <option value="27" name="27">27</option> <option value="28" name="28">28</option> <option value="29" name="29">29</option> <option value="30" name="30">30</option> <option value="31" name="31">31</option> </select> This is an example of the textarea About me: <br /> <textarea name="about" cols="40" value="<?php echo $row['about_me'] ?>"rows="8" > </textarea> <br /> Please help?! Quote Link to comment https://forums.phpfreaks.com/topic/122721-form-database-connection/ Share on other sites More sharing options...
ngreenwood6 Posted September 4, 2008 Share Posted September 4, 2008 Can you elaborate some more as to what you are trying to accomplish? Kind of confused as to what you are trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/122721-form-database-connection/#findComment-633764 Share on other sites More sharing options...
yddib Posted September 4, 2008 Author Share Posted September 4, 2008 Ok sorry. I'll try to be a bit clearer. I have a form which allows people to enter their personal information into the data base. They can then update their information in the database I want to get the information from the database and into the form so they can see what information is already stored. This is working for all input="text" fields but not for the drop down menus or textarea fields that I have above. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/122721-form-database-connection/#findComment-633768 Share on other sites More sharing options...
Maq Posted September 4, 2008 Share Posted September 4, 2008 Quote Link to comment https://forums.phpfreaks.com/topic/122721-form-database-connection/#findComment-633813 Share on other sites More sharing options...
yddib Posted September 5, 2008 Author Share Posted September 5, 2008 <select tabindex="6" name="birthd" id="birthd" value="<?=$row['birthd']?>"class="date"> I don't think this worked ??? Thanks though! Any other suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/122721-form-database-connection/#findComment-634404 Share on other sites More sharing options...
Mchl Posted September 5, 2008 Share Posted September 5, 2008 You've to add selected="selected" to the <option> that has to be selected by default. It's a bit tricky. I think ternary operator <option value="1" name="1" <?php echo $row['birthd'] == 1 ? "selected=\"selected\"" : "" ?>>1</option> is best for this Quote Link to comment https://forums.phpfreaks.com/topic/122721-form-database-connection/#findComment-634420 Share on other sites More sharing options...
yddib Posted September 5, 2008 Author Share Posted September 5, 2008 That's brilliant. Thanks so much. That worked perfectly!.....now I'm just left with the problem of the textarea! If you can help solve this it'd be great! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/122721-form-database-connection/#findComment-634430 Share on other sites More sharing options...
Mchl Posted September 5, 2008 Share Posted September 5, 2008 <textarea name="about" cols="40" rows="8" > <?php echo $row['about_me'] ?> </textarea> Quote Link to comment https://forums.phpfreaks.com/topic/122721-form-database-connection/#findComment-634437 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.