I have 3 table
+----+--------+----+ +----+--------+----+ +----+--------+
+ id + name +perc+ + id + name +perc+ + id + name +
+----+--------+----+ +----+--------+----+ +----+--------+
+ 12 + banana +100 + + 2 + mario +100 + + 1 + apple +
+ 5 + apple + 50 + + 5 + luigi +100 + + 2 + banana +
+ 7 + luigi + 30 + + 99 + apple + 20 + + 3 + input +
+----+--------+----+ + 14 + input + 10 + + 4 + luigi +
+----+--------+----+ + 5 + mario +
+----+--------+
The 3rd table was created from the 1st and the 2nd. In my HTML file there is a table that get all 'name' from table 3. In the first column there are all table3.name and in the 2nd,3rd columns i need to CHECK if the variables are at 100 like this: [V=check but not 100,X=not check,G=check with 100]
+--------+------+------+
+ name + tab1 + tab2 +
+--------+------+------+
+ apple + V + V +
+ banana + G + X +
+ input + X + V +
+ luigi + V + G +
+ mario + X + G +
+--------+------+------+
My code:
$result = $data->query("SELECT t3.name,t2.id t2_id,t1.id t1_id
FROM table3 t3
LEFT JOIN table2 t2 ON t2.name=t3.name
LEFT JOIN table1 t1 ON t1.name=t3.name");
while($line = mysql_fetch_array($result))
{
echo '<tr><td>'.$line['name'].'</td>';
if(!empty($line['t2_id'])) {
echo 'tick'; //for each column
} else { //for each column
echo 'cross';//for each column
}
}
echo "</table>";
my query for the 'perc':
$perc_1 = $data->query("SELECT `perc`FROM `tab1`");
$globe1 = mysql_fetch_array($perc_1);
$perc_2 = $data->query("SELECT `perc`FROM `tab2`");
$globe2 = mysql_fetch_array($perc_2);
i have just try this but not work:
$compare=100;
while($line = mysql_fetch_array($result)){
echo '<tr><td>'.$line['name'].'</td>';
if(!empty($line['t2_id'])) {
if ($globe1 == $compare){
echo 'gold';
} else {
echo 'trick';
}
} else {
echo 'cross';
}
edit:correct some problems.but that don't resolve my problem.I don't have a PHP issue,but i don't know how to check if my var is 100
echo 'cross'doesn't have a;