Select multiple chapters

Created on 31 December 2011, over 12 years ago
Updated 27 February 2024, 4 months ago

I'd like to be able to query multiple chapters (eg /bible/1/GEN/1-3).

Got this working by changing the lines:

        $sqlcmd = sprintf("SELECT * FROM {bible_context} WHERE bid IN (%s) AND book = '%s' AND chapter = %s ORDER BY verse, linemark DESC,%s",
      	  implode(",", $bibles), $book, $chapter, $bid_list);
      }
      $chapter_data = db_query($sqlcmd);

to:

      if (strpos($chapter,"-")) {
        list($chstart, $chend) = explode("-", $chapter,2);
        $sqlcmd = sprintf("SELECT * FROM {bible_context} WHERE bid IN (%s) AND book = '%s' AND chapter BETWEEN %s AND %s ORDER BY chapter, verse, linemark DESC,%s",
      	  implode(",", $bibles), $book, $chstart, $chend, $bid_list);
      }
      else {
        $sqlcmd = sprintf("SELECT * FROM {bible_context} WHERE bid IN (%s) AND book = '%s' AND chapter = %s ORDER BY verse, linemark DESC,%s",
      	  implode(",", $bibles), $book, $chapter, $bid_list);
      }
      $chapter_data = db_query($sqlcmd);

Might need to handle the 'next chapter' link to cope with this as well...

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Matt B

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024