# Random Image from Local DB wont display

**URL:** https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734
**Category:** Questions about Thunkable X
**Tags:** database, beginner, image, randomnumber
**Created:** [August 24, 2021, 2:28am UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734 "2021-08-24T02:28:08Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![ashesdroid](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ashesdroid/32/127531_2.png) [@ashesdroid](https://community.thunkable.com/u/ashesdroid)
#### Post date: [August 24, 2021, 2:28am UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/1 "2021-08-24T02:28:08Z")

</div>

Hello all.

I’ve been struggling to work out how to pull an image from my local database on the project. I’ve already got the DB set up and working - I have another page using the Data viewer List to pull the thumbnails from the local DB images.

I’ve tried multiple ways of blocks and logic and can’t get it to display a random image from the database. My Local DB has 4 Columns: Title, Image reference for the asset, subtitle, and description (to match the Data Viewer List objects for later). I have attached screencaps of 2 ways I’ve tried and a 3rd screencap of Rollin because I used those blocks for reference.

I’m too deep in the weeds here and am running out of idea’s as I am new to this. If you have any idea’s how to pull a random .jpg extension from the Local DB and then display the image on the page I would be really grateful.

Goal: On home page, have a random greeting card display from a list of 50+ cards. I don’t want a button to randomize it; just whenever the page starts. I would create a list manually, but naming 50+ .jpg’s in the list would be bloated. Trying to keep the code clean.

 ![Rollin screencap](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/0/c0ca92187cc69b35ed4e647c0a711a796c6973aa.jpeg)  
 ![Screencap for Random Greeting Image from Local DB based on Rollin](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/d/dd368600acd6960b478d0f718f8e5d9dcb19f7ed.jpeg)  
 ![Screencap for Random Greeting Image from Local DB](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/7/57b1b44657a84cf7c7cd7f006d0f09ddfa55347d.jpeg)

Thank you in advance for any help you can provide. It’s late and I’m burnt out.

P.S. Does anyone know if I have to subscribe with a paid membership for the ability to enable multiline text in Text Input blocks? And Columns?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 24, 2021, 3:00am UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/2 "2021-08-24T03:00:14Z")

</div>

Get rid of this block:

 ![Image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/3/93353a2657795b36874d96e5fb7929c0c3aab704.jpeg)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 24, 2021, 3:02am UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/3 "2021-08-24T03:02:54Z")

</div>

But it also looks like you’re setting your row id variable to an image file name. Try an integer first to see if that works. If not, I can tell you how to get a proper row id from your table.

---

<div class="post-metadata">

### Author: ![ashesdroid](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ashesdroid/32/127531_2.png) [@ashesdroid](https://community.thunkable.com/u/ashesdroid)
#### Post date: [August 24, 2021, 4:13am UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/4 "2021-08-24T04:13:46Z")

</div>

Thank you for the suggestion. This is what I came up with - and it worked one time! Now it wont display again… Puzzling.

 ![Screencap from suggestion](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/0/6061948b187a982881e549d1dc821c32906cf685.jpeg)

I tried a couple other blocks but it started getting needlessly complicated so I reverted back to the above screencap. I added an invisible data viewer so that I could try to pull “row id” blocks but then I drew a blank about where to put it so I just deleted the blocks bet kept the Viewer invisible just in case.

Ideas?  
(as always, thank you for your help!)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 24, 2021, 5:01am UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/5 "2021-08-24T05:01:43Z")

</div>

Now you’ve taken out too much… 😂 Let me see if I can make you demo.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 24, 2021, 5:31am UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/6 "2021-08-24T05:31:46Z")

</div>

Here are three ways to display a random image when the screen opens:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/4/b4c7acf2717c62d2af548303a48d2248202306cb.png)

And the project link if you’d like to try it out:

[https://x.thunkable.com/copy/b8467ce31a2bed6d3be385d33a640268](https://x.thunkable.com/copy/b8467ce31a2bed6d3be385d33a640268)

---

<div class="post-metadata">

### Author: ![ashesdroid](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ashesdroid/32/127531_2.png) [@ashesdroid](https://community.thunkable.com/u/ashesdroid)
#### Post date: [August 24, 2021, 2:42pm UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/7 "2021-08-24T14:42:10Z")

</div>

Oh my gosh! 🤣 I should have just stopped while I was ahead and gone to sleep! This is so simple… I was totally overcomplicating it. The first one works perfectly because all of the cards are going to have the same name and only the number changes to identify it.

I added the join blocks into my own project and it works 100% of the time. You’re a godsend. Thank you! When I get better at Thunkable and start to understand more I will remember you and pass it forward.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 24, 2021, 3:25pm UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/8 "2021-08-24T15:25:40Z")

</div>

You’re welcome! I’m glad it’s working now. I’ve learned a great deal from other folks here so I’m always happy to help when I can.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 24, 2021, 3:28pm UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/9 "2021-08-24T15:28:08Z")

</div>

By the way, unless you have another reason to use the local database, you can do this without adding any data to it. If your image files have sequential names and you know the total number of images, you can just replace the `number of rows in Cards in Table 1` block in the first method I shared with an integer block (e.g. 6 if you have six images).

---

<div class="post-metadata">

### Author: ![ashesdroid](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ashesdroid/32/127531_2.png) [@ashesdroid](https://community.thunkable.com/u/ashesdroid)
#### Post date: [August 24, 2021, 3:44pm UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/10 "2021-08-24T15:44:31Z")

</div>

Oh I see; thank you! Thinking further then, if the final version has 50 cards but only want to pull the first 10 I could just set the integers to 1 to 10? That adds a lot of control if I’m understanding that. I’m going to test it for learning’s sake (I only have 3 cards in the prototype right now, so it’ll be 1-2, excluding the 3rd card).

Or… thinking still: I could hand pick cards and use the Random Item from List: and choose however many I want and hand pick them, using the text block with the name of the .jpg. If I’m understanding that correctly that’s really cool! Thanks @tatiang !

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 24, 2021, 3:53pm UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/11 "2021-08-24T15:53:07Z")

</div>

I think you’ve got it! 😃

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:17pm UTC](https://community.thunkable.com/t/random-image-from-local-db-wont-display/1465734/12 "2024-11-08T13:17:15Z")

</div>


