Page 1 of 1

Getting id number based on logged in user id?

Posted: Mon Oct 29, 2012 11:02 pm
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.

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

Posted: Tue Oct 30, 2012 2:18 pm
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'].