Download & Extend

Select multiple chapters

Project:Bible
Version:7.x-1.4
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

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...

nobody click here