kvnirvana Posted June 1, 2010 Share Posted June 1, 2010 How do I get a text link to run a mysql query when clicked? Say I have the alphabet A b c d e f g ……. When the user clicks on A, it will run a query and show all results that contains A, and so on? Link to comment https://forums.phpfreaks.com/topic/203512-text-link-run-query-when-clicked/ Share on other sites More sharing options...
Pikachu2000 Posted June 1, 2010 Share Posted June 1, 2010 Use a $_GET request and process it based on the $_GET variable's value, or an array of radio buttons with a POST form. Link to comment https://forums.phpfreaks.com/topic/203512-text-link-run-query-when-clicked/#findComment-1066108 Share on other sites More sharing options...
aeroswat Posted June 1, 2010 Share Posted June 1, 2010 How do I get a text link to run a mysql query when clicked? Say I have the alphabet A b c d e f g ……. When the user clicks on A, it will run a query and show all results that contains A, and so on? Best thing might be to make an array filled with the characters of the alphabet. Then you could do a for each loop to go through each one and create a link for it like Pikachu was saying to send a GET variable to whatever page is processing it... something like this $arr = (The alphabet array) foreach($arr as $a) { echo "<a href='www.somesite.com/runquery.php?letter=" . $a . "'>" . $a . "</a>"; } Then runquery.php would have code to access that variable via the following $_GET['letter'] Link to comment https://forums.phpfreaks.com/topic/203512-text-link-run-query-when-clicked/#findComment-1066115 Share on other sites More sharing options...
BizLab Posted June 1, 2010 Share Posted June 1, 2010 I used something like this for a web resource glossary on a recent project.. it uses jquery tabs and a WHOLE LOT of data. Default display is set to query all data related to "A" and when clicked the system will AJAX the data for the new index (letter B for instance). You will need to create an Ajax request for the new information if you want a sleek apearance on this, OTHERWISE You really only need a list of letters (all links) and have the $_GET variable in the link string. Then the recieving page (results.php) will process each string and pull the $_GET['letter_chosen'] data. With that you can now query the database and do a normal dynamic page generation!! Link to comment https://forums.phpfreaks.com/topic/203512-text-link-run-query-when-clicked/#findComment-1066123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.