Agreaves Posted August 9, 2012 Share Posted August 9, 2012 Im creating a catalog of products for sale and I would like to dynamically pull information from a mysql database and display it on a seperate webpage instead of creating different webpages for each product category. Link to comment https://forums.phpfreaks.com/topic/266885-how-to-run-different-sql-queries-with-hyperlinks-connecting-to-a-mysql-database/ Share on other sites More sharing options...
KevinM1 Posted August 9, 2012 Share Posted August 9, 2012 Entirely possible. Do a Google search on 'query string' and look at $_GET. Link to comment https://forums.phpfreaks.com/topic/266885-how-to-run-different-sql-queries-with-hyperlinks-connecting-to-a-mysql-database/#findComment-1368245 Share on other sites More sharing options...
Agreaves Posted August 9, 2012 Author Share Posted August 9, 2012 So I would use the GET string with all hyperlinks to accomplish this? Link to comment https://forums.phpfreaks.com/topic/266885-how-to-run-different-sql-queries-with-hyperlinks-connecting-to-a-mysql-database/#findComment-1368246 Share on other sites More sharing options...
KevinM1 Posted August 10, 2012 Share Posted August 10, 2012 Let's say you have a URL like: www.example.com/index.php?cat=news In your PHP you'd need to check if: 1. 'cat' is present in the URL 2. that it's set to a value you'd accept If so, then load that data: $cat = strtolower($_GET['cat']); switch ($cat) { case "news": // SQL to retrieve news from the db break; // other cases based on whatever you need default: // normal home page } Keep in mind, that's just one way to do it, and it doesn't take security into account. Without knowing exactly what you want to do, I can't give a better answer. Link to comment https://forums.phpfreaks.com/topic/266885-how-to-run-different-sql-queries-with-hyperlinks-connecting-to-a-mysql-database/#findComment-1368251 Share on other sites More sharing options...
Agreaves Posted August 10, 2012 Author Share Posted August 10, 2012 Lets say I have a link to take the customer to a particular called "Ashtrays", whenever they click the link I want it to run a specific query based on ashtrays and output Picture and description of all the ashtrays in the database. However the respose you gave earlier did give me some ideas. Thank you. I hope this information was more specific. Link to comment https://forums.phpfreaks.com/topic/266885-how-to-run-different-sql-queries-with-hyperlinks-connecting-to-a-mysql-database/#findComment-1368258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.