Retrievial Method

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nitation
Forum Newbie
Posts: 10
Joined: Sat Aug 20, 2005 8:18 am

Retrievial Method

Post 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
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Retrievial Method

Post 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 :)
nitation
Forum Newbie
Posts: 10
Joined: Sat Aug 20, 2005 8:18 am

Re: Retrievial Method

Post by nitation »

Thanks .

I got ur logic and i manipulated stuff around.

Cheers.
Post Reply