Jump to content

text link run query when clicked?


kvnirvana

Recommended Posts

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']

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!!

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.