divinedesigns1 Posted August 5, 2012 Share Posted August 5, 2012 hey all i need a little help, with this part, im trying to put the names from the database into a <option> tag in a form, so i was trying to do it like this <form action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="max_size" value="<?php echo GW_MAXFILESIZE; ?>"> <select name="albums" size="1"> <?php $query = "SELECT * FROM krazi"; $result = mysqli_query($con, $query); if($result){ while($rows = mysqli_fetch_array($result)){ echo '<option value="' . $rows['id'] . '">' . $rows['name'] . '</option>'; } } ?> </select> <input type="file" name="upload1"><br/> <input type="file" name="upload2"><br/> <input type="file" name="upload3"><br/> <input type="file" name="upload4"><br/> <input type="file" name="upload5"><br/> <input type="file" name="upload6"><br/> <input type="submit" name="submit" value="Upload"> </form> but this option doesnt work either, i also try to echo out it when its in html but that didnt work either, is there another option to go about doing this? Link to comment Share on other sites More sharing options...
dsonesuk Posted August 5, 2012 Share Posted August 5, 2012 What exactly happens? if you can echo out the id along with names only, you should be able to to echo them out through the option elements of a forms select dropdown list, theres no difference, you are just placing them within option elements value, and text description. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted August 5, 2012 Author Share Posted August 5, 2012 What exactly happens? if you can echo out the id along with names only, you should be able to to echo them out through the option elements of a forms select dropdown list, theres no difference, you are just placing them within option elements value, and text description.so i need to echo them out within the select tags instead of the options tag, correct? Link to comment Share on other sites More sharing options...
dsonesuk Posted August 5, 2012 Share Posted August 5, 2012 No! what you are doing is correct, you don't explain what the problem is? the id, name aren't echo out at all? or not correctly? is it the retrieving of data from database using sql, or while loop problem, what? I was saying IF you can echo out id and name, without including any of the option elements, WITHOUT any problems, there should not be any problem echo out id and WITH option elements. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted August 5, 2012 Author Share Posted August 5, 2012 No! what you are doing is correct, you don't explain what the problem is? the id, name aren't echo out at all? or not correctly? is it the retrieving of data from database using sql, or while loop problem, what? I was saying IF you can echo out id and name, without including any of the option elements, WITHOUT any problems, there should not be any problem echo out id and WITH option elements.oooo now i get what your sayingyes i can check it out, outside of the form but when i try checking it out within the form its a no no Link to comment Share on other sites More sharing options...
birbal Posted August 5, 2012 Share Posted August 5, 2012 if it is printing correct value it should work with option tag. if it does not, check your html source code what it is printing. unless you tell what is not happening like what it should, there will be nothing for us except guessing. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted August 5, 2012 Author Share Posted August 5, 2012 if it is printing correct value it should work with option tag. if it does not, check your html source code what it is printing. unless you tell what is not happening like what it should, there will be nothing for us except guessing.i didnt understand you fully, but what it suppose to be doing is grabbing the information from the database the name and id and displaying it in a drop down list. but according to dsone it should work, so im going to try again and see what happen, i think im doing something wrong tho, so ill go check it out and see what im doing wrong then come back if i get it working Link to comment Share on other sites More sharing options...
boen_robot Posted August 5, 2012 Share Posted August 5, 2012 What HTML code does that output? Right click, "View Source", and paste everything from there here. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted August 6, 2012 Author Share Posted August 6, 2012 What HTML code does that output? Right click, "View Source", and paste everything from there here.in the view source it output the id and not the id, but i got it working tho, instead adding the album_id in the query, i change it to the user_id and it worked like a king lol a good king that is lol, thank for you help guys Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now