Can I hide slides from a slideshow that is connected to a collection, if the db fields the slide is pulling from are all empty ?

I have created dynamic pages for different pain areas (neck, shoulder, ankle etc).
Each dynamic page displays content from a “Pain Management” collection
I use a 9 slide, slideshow connected to the “Pain Management” collection, to display content from each pain area.

On some pain areas i need less slides in my slideshow to display the info necessary. For example on Shoulder page i need 9 slides to display my content while for Neck page i only need 6 slides.
I build the Pain Management DB collection like this:

Because i have less content in the DB collection on the Neck page, slides 7, 8 and 9 appear as empty slides on the site.
Heres slide 7 of the slideshow on the Shoulder page

Here’s slide 7 of the slideshow on the Neck page

For my example, my question is: Is there a way to hide slides 7, 8 and 9 on the neck page if i don’t have any content that links from the db on these slides?

EDIT: I am looking for a solution to work at scale and address hiding slides from slideshows when those slides are connected to empty db fields. The example I gave above is to clarify the problem.

Any help is greatly appreciated. Thank you!

Set the onchange event for the slideshow:
https://www.wix.com/velo/reference/$w/slideshow/onchange

Then, if the current index is slide 7, 8 or 9, change the slide to the last slide.
https://www.wix.com/velo/reference/$w/slideshow/changeslide

Thanks Joel, this is a solid approach.

I think i should have been more clear though that I would need the solution to be scalable to all the dynamic pages and not only address this specific example

Perhaps you can do it like:

if (someDBValue === "") {
    // change to previous slide
}