earwaxaudio Posted February 24, 2009 Share Posted February 24, 2009 Hi everybody. I have recently started learning MySQL and PHP, but have come to a standstill.. I have created a php form which updates a database (which is a list of users with contact details, biography etc.) and worked out how to query the database to display the usernames in a list for browsing. The users are categorised into musicians, actors, etc.. and a different design has been created for each category template page. What I'm stuck with is trying to turn the query results into a list of links that will load the necessary template page and print the data. I would very much appreciate it if someone could help me out. Thanks Rusty. Link to comment https://forums.phpfreaks.com/topic/146613-displaying-mysql-results-on-a-new-page/ Share on other sites More sharing options...
corbin Posted February 24, 2009 Share Posted February 24, 2009 You would just fetch IDs from rows and then pass the ID in the link. Then, on the next page, you would check if it's a valid ID, and if it is, you would load the data into the correct template. How you would know which template could be done two ways: You could either have different tables*, or you could have a column that denotes which type of page. *Note: This one would make more sense if they will have different basic information. I don't know what kind of details you plan on having for each page. Also, if you did it this way, you would either need different pages, or you would have to pass in the URL what kind of person it is (musician or actor for example). Link to comment https://forums.phpfreaks.com/topic/146613-displaying-mysql-results-on-a-new-page/#findComment-769690 Share on other sites More sharing options...
earwaxaudio Posted February 24, 2009 Author Share Posted February 24, 2009 You would just fetch IDs from rows and then pass the ID in the link. Then, on the next page, you would check if it's a valid ID, and if it is, you would load the data into the correct template. How you would know which template could be done two ways: You could either have different tables*, or you could have a column that denotes which type of page. *Note: This one would make more sense if they will have different basic information. I don't know what kind of details you plan on having for each page. Also, if you did it this way, you would either need different pages, or you would have to pass in the URL what kind of person it is (musician or actor for example). Thank you for your help Corbin, although im still a little confused. Sorry to be a pain but are you able to provide me with an example of the script? Here is the browse section on the site i'm working on: http://www.createconnections.comyr.com/browse-profiles/browse.php#2 At the moment the links are directed to seperate pages which clearly is going to be no good. Thank you in advance for anyone that can help. Link to comment https://forums.phpfreaks.com/topic/146613-displaying-mysql-results-on-a-new-page/#findComment-769773 Share on other sites More sharing options...
corbin Posted February 24, 2009 Share Posted February 24, 2009 Find a GET tutorial and read it. Then find a MySQL SELECT tutorial and read it. I can explain it in detail if you want, but I'm quite lazy, and it would take a bit of effort. Link to comment https://forums.phpfreaks.com/topic/146613-displaying-mysql-results-on-a-new-page/#findComment-769786 Share on other sites More sharing options...
earwaxaudio Posted February 24, 2009 Author Share Posted February 24, 2009 Okay cheers ive been having a look around. Apologies for keeping on, but can you just take a look at the script and let me know if you can see an obvious mistake.. Here is what im using to display the html table of results for one of the categories. Im just hoping to add a view profile button to each row which will add the name to the URL. Im guessing i need to add a form using GET, with an action of musician.php for example. I cant seem to find a tutorial that helps me out, are you able to point me in the right direction? I pretty sure im going wrong somewhere with the submit button; i cant seem to get the profile name in the URL... please help :S <?php $result = mysql_query("SELECT * FROM ALLUSERS WHERE CAT='musician' ORDER BY NAME, GENRE") or die(mysql_error()); echo "<table border='1' width='90%' id='t2'>"; echo "<tr><th>Name</th> <th>Genre</th> <th>Record Label</th> <th>Nationality</th></tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo $row['NAME']; echo "</td><td>"; echo $row['GENRE']; echo "</td><td>"; echo $row['RECORDC']; echo "</td><td>"; echo $row['NATIONALITY']; echo "</td><td><form action='../musicians/musician.php' method='GET'><input type='submit' value='profile' name='$NAME'/></form></td> </tr>"; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/146613-displaying-mysql-results-on-a-new-page/#findComment-769840 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.