brownstone4 Posted October 30, 2012 Share Posted October 30, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/270062-getting-id-from-table-database-based-on-logged-in-user-for-link/ Share on other sites More sharing options...
White_Lily Posted October 30, 2012 Share Posted October 30, 2012 er... this is just a random guess since one line of code provided doesn't exactly help much; $query = mysql_query("SELECT id FROM users WHERE username = '$user'"); Quote Link to comment https://forums.phpfreaks.com/topic/270062-getting-id-from-table-database-based-on-logged-in-user-for-link/#findComment-1388758 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.