Jump to content

Searching the database for a range of numbers


kaeRock

Recommended Posts

I have a database of books that users can add to, and one of the fields is the number of volumes they have (it's currently set to varchar in the database). I want other users to be able to search for specific volumes if they want, but if someone has volumes 1-18, they won't type it as 1,2,3,4 etc etc. How can I search the range of volumes without having to type out every number in between? I'm kinda new to PHP. Can I do this through PHP, or do I need to use javascript, or something in the mySQL code? I have no idea!

 

What I want, essentially, is if the user searches for vol 7, and one of the volumes field in the database has 1-9 as its value, it will recognize that 1-9 means that they do have vol 7.

Looks like poor DB design to me. You should read up on structuring it better.

 

If a user has only one volume, then I'm guessing the DB would have it as 5 instead of 5-5, right? And what if a user has volumes 1-3 and volume 5. It's too random for someone to write a SQL for that. Work on DB design.

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.