I've PHP (in combination with PEAR) code like the following:
Code:
$tmp_ram['motherboard_cpu_ram'] = $webdb->getAll(
"SELECT"
. " ram_frequence"
. " FROM"
. " motherboard_cpu_ram"
. " WHERE"
. " motherboard = '".mysql_real_escape_string($pc_data['motherboard']['product_number'])."'"
. " AND"
. " cpu_fsb = '".$pc_data['cpu']['data']->fsb."'"
);
for ($i = 0; $i < sizeof($tmp_ram['motherboard_cpu_ram']); $i++) {
$tmp_ram['motherboard_ram'] = $webdb->getAll(
"SELECT"
. " module_max,"
. " ports_ss,"
. " ports_ds"
. " FROM"
. " motherboard_ram"
. " WHERE"
. " motherboard = '".mysql_real_escape_string($pc_data['motherboard']['product_number'])."'"
. " AND"
. " frequence = '".$tmp_ram['motherboard_cpu_ram'][$i]->ram_frequence."'"
);
for ($x = 0; $x < sizeof($tmp_ram['motherboard_ram']); $x++) {
$tmp_ram['ram'] = $webdb->getAll(
"SELECT"
. " product_number"
. " FROM"
. " ram"
. " WHERE"
. " frequence = '".$tmp_ram['motherboard_cpu_ram'][$i]->ram_taktfrequence."'"
. " AND"
. " modulsize <= '".$tmp_ram['motherboard_ram'][$x]->module_max."'"
);
for ($n = 0; $n < sizeof($tmp_ram['ram']); $n++) {
$tmp_ram['product_numbers_tmp'][] = $tmp_ram['ram'][$n]->product_number;
}
}
}
// remove duplicate entries
$tmp_ram['product_numbers'] = array_unique($tmp_ram['product_numbers_tmp']);
$tmp_ram['product_numbers'] is an array with the product numbers of the compatible articles. So I could select those using for instance:
Code:
SELECT * FROM products WHERE product_number = 1 OR product_number = 2
However this looks pretty weird with like 20 OR's - don't you aggree? Does anybody know a better solution that with the OR's?
Awaiting your answers :-)