I am after a little help with a query to insert a large number of records into a mysql database that I have created. I know that I can probably write a simple script that will do the job for me but I can not get my head around loops and nesting loops etc!
What I am producing on my webpage is a grid 50 columns by 26 rows, each cell will contain a picture of a playing card. Each cell will also have a corresponding record in my database. The grid will appear on 9 different pages, each page being represented by a colour (red, orange, yellow, green, blue, purple, brown, grey and pink).
I have already created the database and it has the following fields:
gridID ..... key
colour ..... colours as above
row ..... letters through A to Z indicating which of the 26 rows
col ..... numbers 1 to 50 indicating which of the 50 columns
x ..... this represents the number of pixels from the left to poistition the card image
y ..... this represents the number of pixels from the top to position the card image
cardID ..... this will refer to a corresponding image record
Most entries to the above fields will be self explanatory but the x value will be in increments of 18 and the y in increments of 22.
Now if my maths are correct, I need 11700 entries into my database table, you can see why I don't want to do these manually!
So what I think I need to do is:
#1 Loop through an array of the colours
#2 Nest into the above loop a second loop to work through an array of the row letters A to Z
#3 Nest into the above loop a third loop to work through the column numbers 1 to 50
#4 Within the above loop, increment the values of x and y by the relevant values
#5 Within the above loop, write a query to insert the data into the table using the values created at each stage of the loops
NB the gridID value is an autoentry and the cardID value is to remain blank at this stage.
Any assistane with this would be very much appreciated, I am sure there are many people out there that would be able to create the required mini script without the blink of an eye.