| 1. |
Solve : [PHP] Pulling information from the database to fill forms?? |
|
Answer» Hey Hopers, what I'm trying to do is pull INFORMATION from my database and display it in html form fields, I'v already worked out how to do this for text but I'm unsure of how to do it with HTML Form Fields like Radio, Checkbox and Select. I imagine it's due to your code expanding to this: When I do that on it's own it outputs a checked radio field, which is what I want but for some reason the field doesn't check with the PHP code, I Guess I'll have to look into my code a little more. edit: Realised the issue was that I was pulling the data via sessionid but I had forgotten to include the file that handles sessions, sorry guys.Wont let me edit my post again, I guess there is a timer For anyone who has this issue and finds this, I ended up changing my method for a more indepth 'failproof' method as the above was returning true if null for some reason. I ended up using an if statement and then calling the session information and then echoing the fields.; Code: [Select]<?php if($session->userinfo["gender"] == "male") { echo '<input type="radio" name="gender" id="gender" value="male" checked>Male' ; } else { echo '<input type="radio" name="gender" id="gender" value="male">Male'; } if($session->userinfo["gender"] == "female") { echo '<input type="radio" name="gender" id="gender" value="female" checked>Female' ; } else { echo '<input type="radio" name="gender" id="gender" value="female">Female'; } ?> Hopefully this can help someone else like me new to this type of PHP Coding Now I'm up to the birthdate field, I could use the above method but It would take quite a few lines to get the correct results, what would be the best way for me to A. Store the Date of Birth and B. retrieve and display it for editing? I'm assuming I'd CONVERT the results into a string for storage but how would I split it back up on retrieving it? |
|