<?php
$sql3 = "SELECT DISTINCT tb_disease.*
FROM tb_disease,tb_digest
WHERE tb_digest.dis_id = tb_disease.dis_id
AND tb_digest.sym_id = '$select[$i]'
order by dis_id
UNION
SELECT DISTINCT tb_value.*
FROM tb_symptom,tb_digest,tb_value
WHERE tb_digest.sym_id = tb_symptom.sym_id
AND tb_value.val_weight = tb_symptom.val_id
AND tb_digest.sym_id = '$select[$i]'
order by dis_id";
$result3 = mysql_query($sql3) or die ("SQL 3 ERROR");
while ($row3 = mysql_fetch_array($result3)) {
?>