Jump to content

Recommended Posts

Hi All,

 

I'm new to PHP so if this is a dumb question appologies.

 

I have a table in mySQL that looks like the following:

 

ID | SYM1 | SYM2 | SYM3 |TAGGED

 

-----------------------------------

 

1  |    7    |    2    |    4    | Yes/No

 

-----------------------------------

 

2  |    6    |    1    |    3    | Yes/No

 

-----------------------------------

 

3  |    9    |    1    |    1    | Yes/No

 

-----------------------------------

 

4  |    9    |    9    |    9    | Yes/No

 

-----------------------------------

 

I need each number to represent an image, like the following:

 

1 = Apple

 

2 = Orange

 

3 = Pear

 

4 = Banana

 

6 = Cherry

 

7 = Strawberry

 

9 = Blackberry

 

Is it possible to do this in PHP, so that if i say use id 1 then images of a strawberry, orange and banana will be displayed????

 

I thought of something like an IF statement along the following lines:

 

IF number1

 

    Choose = Strawberry.jpg

 

        Display Strawberry.jpg

 

The tagged field is simply so that if an ID has been called it gets removed from the database to stop it being called again.

 

Thanks for any help in advance.

Link to comment
https://forums.phpfreaks.com/topic/100455-image-array/
Share on other sites

Again sorry if this is a silly question,

 

But with this code, does this mean if i connected to my database then ran a query something along the lines of:

 

$query = mysql_query ("SELECT * FROM symbolstable WHERE id=1");

 

That query in my eyes would return 7, 2 and 4 - so would this then reference the array and return:

 

Strawberry.JPG

Orange.JPG

Banana.JPG

 

Thanks for your help

Link to comment
https://forums.phpfreaks.com/topic/100455-image-array/#findComment-513730
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.