EchoFool Posted September 5, 2007 Share Posted September 5, 2007 Hello, new here! I have a question on a script im about to create... I'm wondering weather some thing like this could be done... I am creating a form and it is going to show all the rows but only some of the fields relating to each row. Now say it showed like 3 rows.... and 2 of them are identical... though the user can only pick one... how can I get that row that the user picked to find the rowID? I can't use WHERE against the 2 variables that the user has picked, because it'll find more than one row... So i need a clever way for each row being displayed though not showing the ID to the user, yet the ID needs to be along side it so that the process knows which row to deal with when the user has chosen it... Sorry if that sounds a bit confusing... I have not coded it yet by the way. I wanted to see if any knows a way to do this.. possibly like hiding the value of ID but still being loaded in the form :/ ? Let me know any way. Quote Link to comment https://forums.phpfreaks.com/topic/68106-question-about-forms/ Share on other sites More sharing options...
pocobueno1388 Posted September 5, 2007 Share Posted September 5, 2007 Just use a hidden input. <input type='hidden' name='ID' value='<?php echo $row['id']; ?>'> Quote Link to comment https://forums.phpfreaks.com/topic/68106-question-about-forms/#findComment-342342 Share on other sites More sharing options...
Jessica Posted September 5, 2007 Share Posted September 5, 2007 If it's a select (a drop down), make the id the value of the option element. Quote Link to comment https://forums.phpfreaks.com/topic/68106-question-about-forms/#findComment-342347 Share on other sites More sharing options...
EchoFool Posted September 5, 2007 Author Share Posted September 5, 2007 It is a drop down box Jesi... but i'm unfamiliar with what your saying.. could you give me an example and then i can apply it in my own.. ? pocobueno1388 - will try that also... thankyou. Quote Link to comment https://forums.phpfreaks.com/topic/68106-question-about-forms/#findComment-342368 Share on other sites More sharing options...
Jessica Posted September 5, 2007 Share Posted September 5, 2007 A drop down works like this: <select name="yourNameHere"> <option value="value1">Text1</option> <option value="value2">Text2</option> <option value="value3">Text3</option> </select> The relevant PHP code would be on your processing page: $selected = $_POST['yourNameHere']; //will be either value1, value2 or value3 Quote Link to comment https://forums.phpfreaks.com/topic/68106-question-about-forms/#findComment-342370 Share on other sites More sharing options...
EchoFool Posted September 5, 2007 Author Share Posted September 5, 2007 <select name="yourNameHere"> <option value="value1">Text1</option> <option value="value2">Text2</option> <option value="value3">Text3</option> </select> So if i wanted to change option value to ID of row i would do.. <select name="yourNameHere"> <option value="<?=$rowid?>">Text1</option> <option value="<?=$rowid?>">Text2</option> <option value="<?=$rowid?>">Text3</option> </select> But put some form a while loop to do a fetch assoc? Quote Link to comment https://forums.phpfreaks.com/topic/68106-question-about-forms/#findComment-342374 Share on other sites More sharing options...
Jessica Posted September 5, 2007 Share Posted September 5, 2007 Uhm, sure. However you get $rowid is up to you...you just need to start somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/68106-question-about-forms/#findComment-342378 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.