Jump to content


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


mysql wildcards in url

Recommended Posts

I have a numeric paramter that I give it's value in the url like that


sometimes I need to display all the categories how to do that without making a second page , is there a way that I can pass a wildcard character to the select syntax so I get all records ?

sql :

FROM products
WHERE (category_id = colname)

I use $_GET['category_id'] for colname parameter


Share this post

Link to post
Share on other sites
You can do that by not setting the category_id variable or by setting it to 'all'. Then you will need to do a check on it to determine which sql statement you will need to run.


Then you would check it like this.

    $category_id = $_GET['category_id'];

    if($category_id == 'all')
        $sql = "SELECT * FROM products";
        $sql = "SELECT * FROM products WHERE category_id = $category_id";

And then you can run your query with $sql.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

Share this post

Link to post
Share on other sites


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.