phpjayx Posted November 25, 2012 Share Posted November 25, 2012 I've been having trouble getting a parameter passed through PHP from one page to another.... an alternate thought is, since the "name1" below is directly tied to the "userid" in another Table, can I somehow crossreference that table as part of an Insert command? Thanks in advance --------------- $sql_insert = "insert into Data(userid,name1,message1, message2, name2, number1, number2, valid,timestamp,check1,check2)"; $sql_insert .= "value('" . $param['userid'] . "','" . $param['name1'] . "','" . $param['message1'] . "','" . $param['message2'] . "','" . $param['name2'] . "','" . $param['number1'] . "','" . $param['number2'] . "','1','" . $timestamp . "','" . $param['check1'] . "','" . $param['check2'] . "')"; Quote Link to comment https://forums.phpfreaks.com/topic/271137-can-you-cross-reference-other-table-to-insert-data/ Share on other sites More sharing options...
Backslider Posted November 26, 2012 Share Posted November 26, 2012 No you cannot. You are better to register $param['name1'] (I assume this is the one you have trouble with) in $_SESSION and unset it when you are finished with it. Quote Link to comment https://forums.phpfreaks.com/topic/271137-can-you-cross-reference-other-table-to-insert-data/#findComment-1395342 Share on other sites More sharing options...
phpjayx Posted November 27, 2012 Author Share Posted November 27, 2012 Then I must be doing the registering incorrectly, or attemting to use it incorrectly..... I did the following in the .js but having no luck passing it through on my Insert function.... any other hints? <?php session_start(); $name1=$_SESSION["name1"] ; if($name1==NIL)$name1=' '; ?> ---------In the <body> of my php file var name1 = document.getElementById('name1').innerHTML; Quote Link to comment https://forums.phpfreaks.com/topic/271137-can-you-cross-reference-other-table-to-insert-data/#findComment-1395402 Share on other sites More sharing options...
Christian F. Posted December 1, 2012 Share Posted December 1, 2012 The cross-reference is called a "Foreign key relation", and is constructed when you create the table. Or, alternatively, after it has been created. In any case, it's highly advisable to add it before you add any content to the tables. A search on the net should give you lots more information on foreign key relations. If you still have problems with them after reading up, please post what you've tried, what happened/didn't happen and a detailed description of exactly what it is you want to accomplish. Quote Link to comment https://forums.phpfreaks.com/topic/271137-can-you-cross-reference-other-table-to-insert-data/#findComment-1396622 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.