ryan1234 Posted December 9, 2012 Share Posted December 9, 2012 I've got a SQL database that contains the columns id, title and text. On my home page it displays all the rows of the table, but the text (usually many paragraphs of text) is shortened, and there is a link for each 'Read more', which I want it to redirect to a page where the whole text for the specified row is displayed. How do I go about setting up this page? My thoughts are that the id of each text is sent when 'Read more' is clicked and therefore this id can be used to retrieve that row of the table and get the text. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/271768-get-id/ Share on other sites More sharing options...
MDCode Posted December 9, 2012 Share Posted December 9, 2012 Your idea is the correct way to achieving this. Quote Link to comment https://forums.phpfreaks.com/topic/271768-get-id/#findComment-1398298 Share on other sites More sharing options...
ryan1234 Posted December 9, 2012 Author Share Posted December 9, 2012 (edited) At the top of the code I fetch all the rows from the table. I then use a foreach loop to display all the rows individually. Would this code work to send the id: <a href='readmore.php?id=<?php $row['id']; ?>'>Read more</a> Edited December 9, 2012 by ryan1234 Quote Link to comment https://forums.phpfreaks.com/topic/271768-get-id/#findComment-1398304 Share on other sites More sharing options...
MDCode Posted December 9, 2012 Share Posted December 9, 2012 you will need an echo but yes Quote Link to comment https://forums.phpfreaks.com/topic/271768-get-id/#findComment-1398307 Share on other sites More sharing options...
ryan1234 Posted December 9, 2012 Author Share Posted December 9, 2012 Is this the best way of sending the id or... Quote Link to comment https://forums.phpfreaks.com/topic/271768-get-id/#findComment-1398309 Share on other sites More sharing options...
MDCode Posted December 9, 2012 Share Posted December 9, 2012 I'm sure there may be a better way, but most cms and forums use this method Quote Link to comment https://forums.phpfreaks.com/topic/271768-get-id/#findComment-1398310 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.