Jump to content

A simple question


Recommended Posts

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.

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.