bdmovies Posted September 23, 2007 Share Posted September 23, 2007 Hi, I know this is probably a simple question, but I can't seem to figure it out. I have a table called client_information that contains first name, last name, address's and and ID, very basic stuff. I also have a form that inserts information into case_information, that needs to include the client ID. I have a drop down box in the form that is populated by the client_information table, displaying last name, first name (Doe, John). When the user selects on Doe, John and submits, I need to pull the ID associated with Doe, John (we'll say 1 for the example) and insert it into case_information. I can do pretty much everything except get the ID based on the user selection. Quote Link to comment https://forums.phpfreaks.com/topic/70321-a-simple-question/ Share on other sites More sharing options...
bdmovies Posted September 25, 2007 Author Share Posted September 25, 2007 Out of 112 views, someone is bound to know the answer. Am I in the wrong forum? Can someone at least point me in the right direction? Quote Link to comment https://forums.phpfreaks.com/topic/70321-a-simple-question/#findComment-355227 Share on other sites More sharing options...
bsteimel Posted October 5, 2007 Share Posted October 5, 2007 A great way to do this is when you pull the information out of the database use a field id in the options to identify each doe,John with the same client_id as the one in the database. Then when you send the information from your html section to your php section simply include either the id or the name If you don't use the id you must split the name apart from Doe, John to and Doe and John then when you pull the name from the database it will look something like this $name = selectedInformation from html page Or $nameid = selectedinformation ID; $name = explode(",", $name); $qry = "select id from client_info where firstName = '" . $name[1] . "' And lastName = '" . $name[0] . "'" OR $qry = "select id from client_info where clientid = '" . $nameid . "'; $r = pg_fetch_object($result); $r[0] = selected ID Quote Link to comment https://forums.phpfreaks.com/topic/70321-a-simple-question/#findComment-362561 Share on other sites More sharing options...
bsteimel Posted October 5, 2007 Share Posted October 5, 2007 oops i just realized that the code there is for a postgres database, you can follow the same logic but your going to have to use mssql statements instead. The one site that I use with mssql i use stored procs for everything. So instead of using sql statement and getting the result you can just create a insert client info stored proc and send across the id or the john doe name along with the other info Quote Link to comment https://forums.phpfreaks.com/topic/70321-a-simple-question/#findComment-362587 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.