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

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.