Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:51:22+00:00 2026-05-29T03:51:22+00:00

Quick question I have a fully functional database website apart from the filter aspect.

  • 0

Quick question I have a fully functional database website apart from the filter aspect. I had a javascript filter but it would not work with the database properly as it filtered via li class and making it li class=’ . name . ‘ did not work.

Anyway I have attempted to use this method to get around the filter problem.

However I do not know where to run the query that wont create an error hence why it is commented out. Can anyone help or even suggest a better method of going about this?

$result = mysql_query("SELECT * FROM ddcompanies");

/*
while($row = mysql_fetch_array($result)) {
    $cname = $row["company"]; //runs through the company column and populates the array varcompany with those names
    $csect = $row["sector"]; //runs through the website column and populates the array varwebsite with those names
    $cslog = $row["slogan"]; //runs through the story column and populates the array varstory with the text
*/

echo "<ul id='portfolio'>";

if($_GET['link']=='design'){

    echo "design";// TEST
    $result .= "AND sector = 'design'";

echo "<li>
    <a href='single.php?link=" . $cname . "'><img src='images/companies/" . $cname . ".png' alt='' height='115' width='200' />$cname</a>
    <div id='sector'>$csect</div>
    <div id='details'>$cslog</div>
</li>";

}else{
    echo "no way";// TEST
};

Hope you can help or even tell me a better way to do it please.

Thanks in advance!

*EDIT**

On my index page i have a grid or gallery of links (which have an image and some info all pulled from a database).

Each database entry has a field called sector.

I want to be able to only show (filter) the grid items that fall under e.g. Digital (sector name) or Non-Digital (sector name).

So the filter will be using the sector field value in each database entry.

At the moment my links on the index page for filtering are like the following e.g. Design or Development

I hope this is clear enough.

*EDIT**

//QUERY IN EACH

$query = "SELECT * FROM ddcompanies ";
if($_GET['link']=='design') {
    $query .= "WHERE sector = 'design'";
$result = mysql_query($query);
}elseif($_GET['link']=='development') {  
    $query .= "WHERE sector = 'development'";
$result = mysql_query($query);
};

//OR

$query = "SELECT * FROM ddcompanies ";
if($_GET['link']=='design') {
    $query .= "WHERE sector = 'design'";
}elseif($_GET['link']=='development') {  
    $query .= "WHERE sector = 'development'";
};
$result = mysql_query($query);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:51:23+00:00Added an answer on May 29, 2026 at 3:51 am

    it looks like you’re trying to append to your query string based on the URL parameter (link) in the case you posted above. The way you’re doing it won’t work though as $result is a resource, not a string so you can’t just append another string to the resource.

    You’d have to create a string variable for your query, then plug that into your mysql_query() function.

    You’d also have to move the logic up above the string declaration that checks how to revise the query.

    Finally, you need a WHERE clause put in there as just using AND sector = ‘design’ would break the query as it is now.

    EDIT (added some pseudo-code):

    $query = "SELECT * FROM ddcompanies ";
    if(isset($_GET['link']))    
            $query .= "WHERE sector = '".mysql_real_escape_string($_GET['link'])."'";
        $result = mysql_query($query);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a quick question about fetching results from a weakly typed cursor and
I had a quick question regarding RegEx... I have a string that looks something
Quick question regarding Google Maps. I have one fully working Google Maps project and
I am hoping someone can help me out with a quick question I have
I have quick question for you SQL gurus. I have existing tables without primary
I just have a quick question about how to get the length of a
Quick question... I have a query that checks for duplicates that looks like this:
Quick question. I have an app that use a native DLL through PInvoke, this
Quick question, What have I done wrong here. The purpose of this code is
Quick question, is it possible to have an input field in a form use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.