craig1978 Posted April 27, 2007 Share Posted April 27, 2007 Hi Guys, Firstly I am a complete Newbie to all this so please take it slow with the replies. I have created a Search form in html that is processed by a php script via the POST method. All this works pretty well and lists results from my DB. Now i want to be able to click on 1 particular result to bring up a details page. I would like to create this via php so I don't have to create heaps of pages but just a template that uploads data from the DB. Is this possible, and if so, where do i go from here??? I have posted this in the MyQSL forums also. Thanks Craig Link to comment https://forums.phpfreaks.com/topic/48937-search-form-to-results-to-details/ Share on other sites More sharing options...
freakus_maximus Posted April 27, 2007 Share Posted April 27, 2007 Sure you can do this no problem. Your actually almost there with what you have now. On your results page, you want to make a link for each returned row. Assuming you are returning your results in a table using a WHILE loop you could do something like this: //display values if ($bgcolor == "#DAE7F3"){ $bgcolor = "#ffffff"; } else { $bgcolor = "#DAE7F3"; } echo ('<TR>'); echo ('<TD bgColor="'.$bgcolor.'"><A href="http://yoursite.com/details.php?id='.$row[0].'">'.$row[0].'"></A></TD>'); echo ('<TD bgColor="'.$bgcolor.'">'.$row[1].'</TD>'); echo ('<TD bgColor="'.$bgcolor.'">'.$row[2].'</TD>'); echo ('<TD bgColor="'.$bgcolor.'">'.$row[3].'</TD>'); echo ('</TR>'); This will create a link for each returned row from your database. The $row[] is just an assumption that you are pulling everything in your initial query and displaying column 0, 1, 2, 3, etc... Also, not that you needed but it was part of my snippets, this will alternate background colors for each row. You would need a "details.php" page to $_GET['id'] and use that to query all the details of that record and display them how you want. Hope that helps! Link to comment https://forums.phpfreaks.com/topic/48937-search-form-to-results-to-details/#findComment-239808 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.