Page 1 of 1

Retrievial Method

Posted: Sat Jul 12, 2008 5:37 pm
by nitation
Good day Gurus.

I have an admin area where i add an amount. What i wanna achieve is, i wanna select a user_id from table x and insert it to table y for a specific user. Note: the specific user's ID is retrieved from table x in a drop down menu. How do i get the user_id from table x and insert it to table y since my drop down menu will list all the user's in the table. That means my user's sessions is not applicable here since am in the admin area.

Thanks in advance

Re: Retrievial Method

Posted: Sat Jul 12, 2008 6:32 pm
by alex.barylski
When you submit the FORM which contains the dropdown, the value of each element should be the user_id of the user:

Code: Select all

<label>Users</label<select name="userid">  <option value="1">George</option>  <option value="2">Bobby</option>  <option value="3">Sammy</option></select>
Whatever user is selected the user ID is passed to your script at which point you would then create a new record with the user_id as a foriegn key or primary key -- I have no idea what your trying to accomplish.

Basically, given two tables:

Code: Select all

table1:
pkid, username, email, first_name, last_name
 
table2:
pkid, user_id, comments
I assume you are trying to record some action carried our or assigned to a specific user?

In which case table1 would be your primary table that holds details about a user and table2 would be the table you are using to record some action or event associated with userX.

So when you record an event you would do something like:

Code: Select all

 
<?php
 
  $userid = $_POST['userid'];
 
  $comment = 'This is some comment you want associated with user ID';
 
  recordEventOrWhatever($userid, $comment);
 
Cheers :)

Re: Retrievial Method

Posted: Sat Jul 12, 2008 6:48 pm
by nitation
Thanks .

I got ur logic and i manipulated stuff around.

Cheers.