Casual-T Posted May 9, 2009 Share Posted May 9, 2009 Hi, I am working on a news system with a MySQL database, of course. Right now, the news system undergoes a series of three pages: 1. Page with the news form to be processed. 2. Page that processes the form, inserts all the info into the DB, writes to a new file, and redirects the user to a page with a link to their newly created file. 3. Page that displays the information that was filled out in page 1 and is also the page that the user is taken to when they click on their link in page 2. What I need to know is, how can I display data on each new "Page 3" that is created and is relevant to the information that was filled out for that specific page. For example, if a user fills out the news form, a link and a "Page 3" will be created that displays the information they filled out from Page 1. Then, when they go back and fill out the news form again, the new page should display information that is DIFFERENT from the first posting. Right now, my issue is that every "Page 3" that is created shows the information from each instance of posting, when I only want it to show the information from when that page was posted. If it helps, I have a "news_id" column that basically just auto-increments when something new is posted. Right now, the number in that column is up to 91 since I've tested it so many times. I hope anyone can help and that you understand what is going on here Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/ Share on other sites More sharing options...
fenway Posted May 11, 2009 Share Posted May 11, 2009 You need to keep track of the news_id in your session. Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-831551 Share on other sites More sharing options...
Casual-T Posted May 11, 2009 Author Share Posted May 11, 2009 I am not using sessions. I did try using a session for this, but that only pulled the same information on each new page that was created. I figure that SELECTING specific rows from the database to be displayed would be much easier and efficient. I would like to stick to "SELECTING" from the database instead of using a session, but if I did switch back to a session and track the news_id column like you said, do you think it will remember the data that was posted for each news posting? Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-831777 Share on other sites More sharing options...
fenway Posted May 11, 2009 Share Posted May 11, 2009 I don't know what you mean... somehow you have to store the newly created news_id somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-831845 Share on other sites More sharing options...
Casual-T Posted May 13, 2009 Author Share Posted May 13, 2009 each newly created news_id is stored as a new row in the database. I will save this post so I can edit it when I have more time so that I can provide a screenshot of the table and hopefully provide more details Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-832929 Share on other sites More sharing options...
Casual-T Posted May 13, 2009 Author Share Posted May 13, 2009 I have created this graphical representation to hopefully clarify things: http://www.shaunmilodesigns.com/newsformlayout.jpg (1440x900 resolution) Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-833040 Share on other sites More sharing options...
fenway Posted May 13, 2009 Share Posted May 13, 2009 each newly created news_id is stored as a new row in the database. I will save this post so I can edit it when I have more time so that I can provide a screenshot of the table and hopefully provide more details Yes, I know that... I mean if you want to "get it back" on another page you need to create continuity -- which means storing something you can use to get it back. Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-833231 Share on other sites More sharing options...
Casual-T Posted May 13, 2009 Author Share Posted May 13, 2009 each newly created news_id is stored as a new row in the database. I will save this post so I can edit it when I have more time so that I can provide a screenshot of the table and hopefully provide more details Yes, I know that... I mean if you want to "get it back" on another page you need to create continuity -- which means storing something you can use to get it back. But it IS being stored.... in the database. That way I can pull the information from the DB to be displayed on whatever page I want (i.e. getting it back) I don't seem to understand what you're wanting me to store Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-833393 Share on other sites More sharing options...
fenway Posted May 13, 2009 Share Posted May 13, 2009 Right now, my issue is that every "Page 3" that is created shows the information from each instance of posting, when I only want it to show the information from when that page was posted. Since your scripts can't be "psychic", you need to "store" the news_id from the most recent Page 1 submission. Your DB will not help you here. Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-833447 Share on other sites More sharing options...
Casual-T Posted May 13, 2009 Author Share Posted May 13, 2009 I found some other help online and it was suggested to me that I store the news title in the URL of each news link (using $_GET), that way every Page 3 will display the title from that specific posting. My only issue now is that the Page 3's are not showing the information from the news_text column. The way I have it is as follows: <?php $id=$_GET['title']; //get the title from the url $info_query = "SELECT news_text FROM news WHERE news_title=$id"; $info = mysql_query($info_query); echo $id; echo $info; ?> Technically, it is supposed to show the information in the news_text column that is related to the news_title, but it is only showing the news_title. Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-833598 Share on other sites More sharing options...
fenway Posted May 14, 2009 Share Posted May 14, 2009 mysql_query() returns a resource... not sure what you're expecting without calling fetch_array(). Also, that script is vulnerable to sql injection. Maybe you should take a look at some of the stickies that have tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-834346 Share on other sites More sharing options...
Casual-T Posted May 15, 2009 Author Share Posted May 15, 2009 Ok, thanks for all the help. I'm sure I will get it working considering how close I am. I just need to fetch the row I need with the id's Quote Link to comment https://forums.phpfreaks.com/topic/157511-solved-displaying-data-from-different-rows-on-different-pages/#findComment-834491 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.