Forum Moderators: coopster
i want to write a sitemap.xml file for one of my pages. the url will always have two query strings on it. and each string could be one of 300 different possibilities.
so the url might look like this...
example.com/page.html?var1=red&var2=apple
i have worked out that there are approxiametly 100,000 different combinations of the two variables. which would take ages to write out in a sitemap. eg.
var1=red&var2=apple
var1=red&var2=orange
var1=red&var2=pear
var1=green&var2=apple
var1=green&var2=orange
var1=green&var2=pear
does anyone know a way to do a little php script that could print out all the different combinations?
let us know if it could do the trick
If so, the logic is simple enough..
Step 1 - Query the db to get the first result set that contains all the possible variations of var1. You'll likely need to use the DISTINCT command to get only 1 version of each variation.
Step 2 - Create a while loop to iterate through the result set returned from step 1
Step 3 - Inside the while loop created in Step 2, you will need a 2nd db query to grab the result set that contains all the possible variations for var 2 (again using the DISTINCT command I'm betting).
Step 4 - Create a 2nd while loop inside the first while loop to iterate through the 2nd result set returned.
Step 5 - Print out the data
Basically, you want to grab a version of var 1, then cycle through all the possible versions of var 2, then move to the next version of var 1, rinse..repeat
at least that's how I'd do it :)
[edited by: Philosopher at 4:11 pm (utc) on Jan. 20, 2009]