Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Create a link that searches a recordset

New Here ,
Jun 19, 2009 Jun 19, 2009

Copy link to clipboard

Copied

Newbie here. I have an MYSQL database where each item has a "category" column. I am trying to have a page that lists all of the possible categories, and when you click on one of the links, it takes your to a page with a recordset that is filtered for that category. I know how to filter my recordset by category but my question is how do I make a link that will instruct the server to filter the recordset based on the selected category? Thanks for any help somebody can offer.

TOPICS
Server side applications

Views

663
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2009 Jun 19, 2009

Copy link to clipboard

Copied

Moved to the Dreamweaver Application Development forum, which deals with PHP/MySQL and other server-side issues.

The way to handle this issue is to use a query string at the end of the URL. A query string consists of a question mark followed by one or more name/value pairs. If there is more than one name/value pair, separate each pair with an ampersand. So, to select your category you would create something like this:

<a href="details.php?category=software">See software details</a>

You filter the recordset in details.php using a URL parameter to set the value of the category column to software.

If you are creating a page to build these links automatically, you need to create a recordset of all the categories, and loop through a repeat region using the recordset value:

<a href="details.php?category=<?php echo $row_recordsetName['category']; ?>">
See <?php echo $row_recordsetName['category']; ?> details</a>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 23, 2009 Jun 23, 2009

Copy link to clipboard

Copied

LATEST

Assuming in that item table, the category value is

1. Integer

   <a href="details.php?id=<?php echo $row_getItems['category']; ?>">Click Here</a>

Then in your browser the URL will be

www.yoursitename.com/details.php?id=1

2. String

   <a href="details.php?id=<?php echo $row_getItems['category']; ?>">Click Here</a>

Then in your browser the URL will be

www.yoursitename.com/details.php?id=technology

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines