$query_posts = "
SELECT DISTINCT meta_value
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'Product'
AND wposts.post_status = 'publish'
AND wposts.post_type = 'post'
ORDER BY wposts.post_date DESC";
$result = mysql_query($query_posts) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['meta_value'];
}
The above produces a list of results as below:
235/40/R18/95/ZR(Y)/XL £180.00
225/45/R17/94/W/XL £180.00
235/45/R17/97/Y/XL £180.00
245/45/R17/99/Y/XL £180.00
245/40/R17/91/Y £180.00
225/40/R18/92/W/XL £180.00
etc etc
They are tyre sizes if you didn't guess. I need to break the first three values into distinct relational menus: Trye Width / Sidewall / Rim
I worked out that if I use:
$query_posts = "
SELECT DISTINCT meta_value
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'Product'
AND wposts.post_status = 'publish'
AND wposts.post_type = 'post'
ORDER BY wposts.post_date DESC";
$result = mysql_query($query_posts) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$tyres_widths = (explode("/",$row['meta_value']));
echo ($tyres_widths[0]);
}
I can get the first ($tyres_widths[0]), second ($tyres_widths[1]) or third column ($tyres_widths[2]), but the values are not distinct and of course I have still not got to the point when they are relational in menus.
Is my approach correct? There has got to be a better method? Can someone assist. I am happy to reward for correct answer and of course someone else can benefit which is the whole point!!
Thanks in advance
Stu