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 6983509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:25:41+00:00 2026-05-27T18:25:41+00:00

i have a row in my database with name active_sizes and i want filter

  • 0

i have a row in my database with name “active_sizes” and i want filter my website items by size, for this, i use LIKE Condition in php :

AND active_sizes LIKE '%" . $_GET['size'] . "%'

but by using this code i have problem

for example when $_GET['size']=7.0 this code shows items that active_sizes=17.0

my active_sizes value looks like 17.0,5.0,6.5,7.5,,

thanks

  • 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-27T18:25:42+00:00Added an answer on May 27, 2026 at 6:25 pm

    Using comma-separated values in a single field in a database is indicative of bad design. You should normalize things, and have a seperate “item_sizes” table. As it stands now, you need a VERY ugly where clause to handle such sub-string mismatches:

    $s = (intval)$_GET['size'];
    
    ... WHERE (active_sizes = $s)   // the only value in the field
          OR (active_sizes LIKE '$s%,') // at the beginning of the field
          OR (active_sizes LIKE '%,$s,%')  // in the middle of the field
          OR (active_sizes LIKE '%,$s') // at the end of the field
    

    Or, if you normalized things properly and had these individual values in their own child table:

    WHERE (active_sizes_child.size = $s)
    

    I know which one I’d choose to go with…

    You don’t state which DB you’re using, but if you’re in MySQL, you can temporarily accomplish the same thing with

    WHERE find_in_set($s, active_sizes)
    

    at the cost of losing portability. Relevant docs here: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that looks like this: ID parent name description _record_status _log_user
i have a UITableView where i want one cell(database row) needs to be default,
ok i have a complete form in my database as row for example name
I have a problem when I want to update a row in a database.
I want get from database table row name but in it i get error.
I want foreach a row from database and get value it, but have error:
I want insert following checkbox in a row from database table, but have error,
I have a row of data that I need to modify in a database,
Say I have an ID row (int) in a database set as the primary
I have a method that deletes a row form a database using the sql

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.