Getting id number based on logged in user id?

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
brownstone4
Forum Newbie
Posts: 2
Joined: Wed Jan 18, 2012 11:27 pm

Getting id number based on logged in user id?

Post by brownstone4 »

Hi,

New to php coding and using Joomla and have a question about how to write a query to the database to create a new link. Basically I am trying to create a link on a page which will link to the 'item' page of logged in user. So at the moment the link below will link to the currently viewed item of another user.
<a href="<? echo JRoute::_('index.php?option=com_prod&view=item&id=' . $this->item->id); ?>

What I need to do is make the link go to the item of the user who is logged in when they click on it. In the database under '_prod_items' for example there is rows with the item id 'id' and the user id 'user_id'. The component functions in a way so that users can only create one 'item'. So how can I make a query to get that item 'id' to put in a link based on the 'user_id' that is logged in?

Thanks.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Getting id number based on logged in user id?

Post by califdon »

brownstone4 wrote:Hi,

New to php coding and using Joomla and have a question about how to write a query to the database to create a new link. Basically I am trying to create a link on a page which will link to the 'item' page of logged in user. So at the moment the link below will link to the currently viewed item of another user.
<a href="<? echo JRoute::_('index.php?option=com_prod&view=item&id=' . $this->item->id); ?>

What I need to do is make the link go to the item of the user who is logged in when they click on it. In the database under '_prod_items' for example there is rows with the item id 'id' and the user id 'user_id'. The component functions in a way so that users can only create one 'item'. So how can I make a query to get that item 'id' to put in a link based on the 'user_id' that is logged in?

Thanks.
If I understand your description of your logic, you need to query the database by user_id, not item_id, but it's hard to know without seeing the logic your index.php script uses to handle the URL that calls it; in other words, show us the part of your script that uses $_GET['option'], $_GET['view'] and $_GET['item'].
Post Reply