0

I am very new to PHP and am trying to find the best solution to my problem. In my database I have a field "painters". Within painters I have "painter A", "Painter B",and "Painter C". Is their a way to display painter c if certain art work comes up? Or Painter "B", if a certain art work comes up? I am trying to understand the best way to do something like this dynamically. Any links, code, or tutorials would help me tremendously! Thanks so much in advance!

-Mike

2
  • 2
    try google beginner php mysql tutorial Commented Jul 20, 2012 at 19:45
  • Well I think thats what I am asking. I am trying to find out the best thing to research to get my answer. This is part of my research :). Commented Jul 20, 2012 at 19:46

2 Answers 2

1

You are going to want 3 tables. A "Painters" table, a "assoc" table, and a "Painting" table.

Painters table includes:

  • ID
  • Name
  • DOB
  • Phone
  • Address
  • Blah
  • blah

Painting table includes:

  • ID
  • Name
  • Date_Created
  • Blah
  • Blah
  • Blah

Assoc table links them... It looks like:

  • ID
  • PAINTER_ID
  • PAINTING_ID

So you can say SELECT PAINTING_ID FROM 'ASSOC' WHERE PAINTER_ID = '$Your_variable' Then with that result set iterate through that array with a foreach.

Inside that foreach: you will
SELECT * FROM PAINTINGS WHERE ID = Array['PAINTING_ID'].

That's a basic associative relational database.

You can google more about it, but that's the basics that should get you started

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks very much for the example, it really helps me grab a better understanding of it.
0

Start by reading these W3 tutorials.

http://www.w3schools.com/php/php_mysql_connect.asp

If you are like me and you need a visual aid then watch this tutorial, without this guy I wouldn't know anything about PHP, and I wouldn't have been able to creat my own CMS software, which I use for many of my clients.

For some reason the link won't post so Google "build a cms php youtube" and then click on the first video result :)

In future, it is good to try it yourself, and when you stumble upon problems, post on Stack Overflow, your question was a little to vague here.

1 Comment

Hey Mr.Stuart, sorry would you mind re-posting that you tube link, I think its broken.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.