kaeRock Posted May 3, 2009 Share Posted May 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/156661-searching-the-database-for-a-range-of-numbers/ Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/156661-searching-the-database-for-a-range-of-numbers/#findComment-824983 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.