Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 1st, 2005, 03:36 PM
Registered User
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gsedrak1
Default How I store & retrieve List/Menu Mysql/PHP

Please tell me;
How I store and retrieve Jump List/Menu to and from Mysql
database using PHP
<table align="center">
  <tr valign="baseline">
    <td nowrap align="right">SmokingHabits:</td>
    <td><span class="stdBold"><strong>
      <select name="SmokingHabits" title="<%=(WcsdUserProfile2.Fields.Item("SmokingHa bits").Value)%>" value="" >
        <option value="1" selected>Choose</option>
        <option value="2" >Non-Smoker</option>
        <option value="4" >Occasional Smoker</option>
        <option value="8" >Smokes Regularly</option>
        <option value="16" >Trying to quit</option>
    </strong></span> </td>
<table align="center">
  <tr valign="baseline">
    <td nowrap align="right">BirthDate:</td>
    <td><select name="mnth" id="mnth" title="<?php echo $row_rsProfile['BirthDateMonth']; ?>">
        <option value="" selected>Month</option>
        <option value=01>January</option>
        <option value=02>February</option>
        <option value=03>March</option>
        <option value=04>April</option>
        <option value=05>May</option>
        <option value=06>June</option>
        <option value=07>July</option>
        <option value=08>August</option>
        <option value=09>September</option>
        <option value=10>October</option>
        <option value=11>November</option>
        <option value=12>December</option>
        <select name="day" title="<?php echo $row_rsuserprofile['BirthDateDay']; ?>">
          <option value="" selected>Day</option>
          <option value=01>01</option>
          <option value=02>02</option>
          <option value=03>03</option>
          <option value=04>04</option>
          <option value=05>05</option>
          <option value=06>06</option>
          <option value=07>07</option>
          <option value=08>08</option>
          <option value=09>09</option>
          <option value=10>10</option>
          <option value=11>11</option>
          <option value=12>12</option>
          <option value=13>13</option>
          <option value=14>14</option>
          <option value=15>15</option>
          <option value=16>16</option>
          <option value=17>17</option>
          <option value=18>18</option>
          <option value=19>19</option>
          <option value=20>20</option>
          <option value=21>21</option>
          <option value=22>22</option>
          <option value=23>23</option>
          <option value=24>24</option>
          <option value=25>25</option>
          <option value=26>26</option>
          <option value=27>27</option>
          <option value=28>28</option>
          <option value=29>29</option>
          <option value=30>30</option>
          <option value=31>31</option>
        <select name="yr" title="<?php echo $row_rsuserprofile['BirthDateYear']; ?>">
          <option value=1944>1944</option>
          <option value=1945>1945</option>
          <option value=1946>1946</option>
          <option value=1947>1947</option>
          <option value=1948>1948</option>
          <option value=1949>1949</option>
          <option value=1950>1950</option>
          <option value=1951>1951</option>
          <option value=1952>1952</option>
          <option value=1953>1953</option>
          <option value=1954>1954</option>
          <option value=1955>1955</option>
          <option value=1956>1956</option>
          <option value=1957>1957</option>
          <option value=1958>1958</option>
          <option value=1959>1959</option>
          <option value="" selected>Year</option>
          <option value=1990>1990</option>
          <option value=1991>1991</option>
          <option value=1992>1992</option>
          <option value=1993>1993</option>
          <option value=1994>1994</option>
          <option value=1995>1995</option>
          <option value=1996>1996</option>
          <option value=1997>1997</option>
          <option value=1998>1998</option>
          <option value=1999>1999</option>
          <option value=2000>2000</option>

George Sedrak
Old August 2nd, 2005, 05:17 PM
Friend of Wrox
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts

You should create two tables. One for Smoking habits.

Some sample values
2 Non-Smoker
4 Occasional Smoker
8 Smokes Regularly
16 Trying to quit

As for dates there are many ways of doing this. If you want to write good code and account for things like leap year. You need a table that has one row for every day for a time range. Say for example 1980 - 2020. Then only populate it with valid dates. There should be no Feb 30 of any year but there should be a leap year when appropriate. Problem here is you also need to put in logic in the php as well as the database unless you want to make multiple hits to get the date. For example, select year and month, then possible dates for that month are populated. Another way is to allow the user to select feb 30, then validate against the database to see if its a valid date or not. Rejecting the value if its not appropriate. I prefer to do both simultaneous. Write a java script function that creates the possible values based on the year/month selected. You can't do this with PHP accurately without multiple hits against the web server. Then I validate that yeat again against the database.

Hope this helps
Old September 15th, 2005, 07:59 PM
Friend of Wrox
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts

What the hell I did not post that last one???? Something wrong with the server?

Old September 15th, 2005, 08:49 PM
Friend of Wrox
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts

Sorry people please ignore the previous post under my name, a dysfunctional friend, who thinks he is funny, got to my computer...... I did make the first and third post but not the second.... Your servers are just fine.....

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql & php connection problem. Manu Sharma PHP Databases 2 March 2nd, 2007 07:03 AM
begin php & mysql - chapter 12, user_form.php jon_stubber Beginning PHP 1 March 9th, 2006 10:57 AM
php, mysql, apache & dreamweaver seanhsueh PHP Databases 1 December 9th, 2005 08:12 AM
Store Items from dropdown menu in mysql database scoobie PHP Databases 0 April 28th, 2005 08:17 AM
PHP & MySQL d-dubu MySQL 2 January 14th, 2005 01:32 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.