Jump to content

Form database connection


yddib

Recommended Posts

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?!

Link to comment
https://forums.phpfreaks.com/topic/122721-form-database-connection/
Share on other sites

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

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

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.