Jump to content

Can You Cross Reference Other Table To Insert Data?


phpjayx

Recommended Posts

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'] . "')";

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;

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.

Archived

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.