Help with linking two tables

Does this inserr statement work with no errors?

The only error that I get is with the Select statement at the end for the DeviceID - everything else gives me the value that I want

is there a drop down of some sort where user selects Device what you have will not work

The user will type down the device they are using :confused: which I understand now why it may cause issues. Is there any possible way in which I would be able to what device/user based on the first table has given what results in second table? Maybe not necessarily through foreign keys

They type it? What if they type Mickey Mouse? Do you not have a list of devices? Or have they added their device name in a previous step or screen

Yeah I've given the user full control of what they type in a screen before the performance task screen, the typing of the device is more just an extra measure - the height and width of the device they are using is collected and that is what I am more interested in

So what they type as device does it get saved? In a tablenof devices? If not you will not have DeviceId

Yeah whatever they type will be saved inside of the device table along with the other informaton and this will give an auto-incremented devicecID

then they go to next screen? or same screen? Either way how does the system,program,application know which device it is at the next step? Is there an indication on the screen or application?

Yeah they will be taken to another page where the performance task will begin. The information relating to the device will be sent to a php page where it is stored in my database.

No, what I am asking is the "other page where the performance task will begin" does that performance page know anything about the current device being used?

I was just testing the page and yeah it doesn't look like it is aware of the device being used. Sorry to ask another question, but what would be the best way ensure that it is aware of the information of the device. Many thanks!

No problem. You have to create means for the user to select the device being tested/performance. Either a list view with check-boxes, a drop down or some other means for the user to select the current device they just entered, or the device in question.

When they choose one, behind the scenes you have the deviceId then you send that to your insert statement. The other challenge you will face is how do they know which device it is. If you have many users and they all name the device the same way, Darth Vader, how can you differentiate? Maybe add, in parenthesis the name of the person that created the device, and maybe also date. by the way, your INSERT, might be better if you changed it, eventually, to use a stored procedure. baby steps first. Currently your issue is not SQL Server, it is your application.

For more details on php related stuff you will have to consult other sites?

Ah okay I'm kind of following -sorry just to make clear however at the moment I am receiving the data for the first table with the device name and deviceID being auto-incremented however it is just not connected to the php page in which the second table's data is sent to. Is there anyway in which this ID based off the height and width of the screen along with the name can be sent to this second php page or am I missing the mark a bit, thanks again for the help. (In terms of differentiating the device I am more interested in the height and width of each device which is stored - letting the user enter the device is more of an additional feature)

I hear you but none of it has anything to do with SQL server. again it is an issue with your web page design and not a SQL issue. Fix your web page and the rest will sort itself out.

1 Like

hi

hope this helps :slight_smile:

if you want to join device to user...there has to be a connection or link ( however or whatever )

you can create an intermediate table with LINK ..
DeviceID ( device) INT
ResutlID ( user ) INT
DeviceResult Link Connection INT

The issue is the web site he has developed and not a sql linking issue

gotcha
:+1: :+1: