genzedu777 Posted January 31, 2011 Share Posted January 31, 2011 Hi all, Currently my dob_day is not showing any value, even though there is a value in the database, it seems like it is unable to retrieve the value. No value was shown in the <select> box. Do you guys have any idea? Thanks <?php $query = "SELECT name, nric, gender, picture, dob_day FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // The user row was found so display the user data if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $nric = $row['nric']; $gender = $row['gender']; $old_picture = $row['picture']; $dob_day = $row['dob_day']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } //HTML CODING <label for="dob" class="label">Date Of Birth</label> <select id="dob_day" name="dob_day" value="<?php if (!empty($dob_day)) echo $dob_day; ?>"> <option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> ?> [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
atrum Posted January 31, 2011 Share Posted January 31, 2011 Let's see your table from your database. Quote Link to comment Share on other sites More sharing options...
genzedu777 Posted January 31, 2011 Author Share Posted January 31, 2011 Hi this is my Database table [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 31, 2011 Share Posted January 31, 2011 You have an extraneous, unclosed <option> tag at the beginning of the <select>. Quote Link to comment Share on other sites More sharing options...
atrum Posted January 31, 2011 Share Posted January 31, 2011 Add this above the line starting with "if ($row != NULL)" print_r($row); That should print the array of data you pulled down for tutor_id. Show me what that gives you. EDIT: Doh!, I missed <option> error that pikachu2000 pointed out . Quote Link to comment Share on other sites More sharing options...
genzedu777 Posted February 5, 2011 Author Share Posted February 5, 2011 Hi Atrum, Sorry for the late response. Hey I got values in the date of birth, but it is still not showing in the drop down box. What could possibly be happening? Thanks Array ( [0] => MUHAMMAD [name] => MUHAMMAD [1] => S89362A [nric] => S89362A [2] => M [gender] => M [3] => belitapic.jpg [picture] => belitapic.jpg [4] => 16 [dob_day] => 16 ) Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 The <select> tag doesn't get a value= attribute, however each <option> should have one. Currently the <option>s do not have value= attributes. Quote Link to comment Share on other sites More sharing options...
genzedu777 Posted February 5, 2011 Author Share Posted February 5, 2011 Hi Pikachu2000, Thanks for replying. However I still dont really get what you have meant Currently the value for dob_day = '16' However '16' is not reflected in my drop down box, apparently it is 'blank'. Under my option, I do have <option>16</option>, what do you mean by Currently the <option>s do not have value= attributes. Could you elaborate further? Thank you so much <?php <?php $query = "SELECT name, nric, gender, picture, dob_day FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // The user row was found so display the user data if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $nric = $row['nric']; $gender = $row['gender']; $old_picture = $row['picture']; $dob_day = $row['dob_day']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } //HTML CODING <label for="dob" class="label">Date Of Birth</label> <select id="dob_day" name="dob_day" value="<?php if (!empty($dob_day)) echo $dob_day; ?>"> <option value=''></option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> ?> ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 <select> tags do not get value= attributes. <option> tags do. You have it backwards. <select name="day"> <option value="1">Sunday</option> <option value="2">Monday</option> </select> Quote Link to comment Share on other sites More sharing options...
genzedu777 Posted February 5, 2011 Author Share Posted February 5, 2011 Hi Pikachu2000, I have followed your advice, but it still didnt work, I have done up to option value = '16', but there is no value in my drop down box. Did I miss out anything? Thanks <td><select id="dob_day" name="dob_day" value="<?php if (!empty($dob_day)) echo $dob_day; ?>"> <option value=''></option> <option value='1'>01</option> <option value='2'>02</option> <option value='3'>03</option> <option value='4'>04</option> <option value='5'>05</option> <option value='6'>06</option> <option value='7'>07</option> <option value='8'>08</option> <option value='9'>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> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 I already told you twice: <select> tags do not get a value= attribute. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted February 5, 2011 Share Posted February 5, 2011 Did no-one else spot the closing tag at the end of the script, that should infact be above the above the Label and Select? <?php $query = "SELECT name, nric, gender, picture, dob_day FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // The user row was found so display the user data if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $nric = $row['nric']; $gender = $row['gender']; $old_picture = $row['picture']; $dob_day = $row['dob_day']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } //HTML CODING BELOW ?> <label for="dob" class="label">Date Of Birth</label> <select id="dob_day" name="dob_day" value="<?php if (!empty($dob_day)) { echo $dob_day; } ?>"> <option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> Try that? Unless you noticed this before the just disregard this post. Regards, PaulRyan. 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.