I have two Mysql tables:
Table1 columns => Name,Firstname,Age,Address
Table2 columns => Name,School,Car,Whatever
So both tables contain the same column "Name".
I need to create an html table with all data from table1 BUT when Table1 name = Table2 name I want to colour the corresponding table row in red.
can you help me to achieve that please?
I can create a html table with data from table1:
echo '<table id = "mytable" border="1" cellpadding="10" width="100%" >';
echo '<th align="center"> Name </th>';
echo '<th align="center"> First Name </th>';
echo '<th align="center"> Age </th>';
echo '<th align="center"> Address </th>';
while($data =mysql_fetch_array($query)){
echo "<tr><td align='center'>". $data["Name"]." </td>";
echo "<td align='center'>". $data["Firstname"]." </td>";
echo "<td align='center'>". $data["Age"]." </td>";
echo "<td align='center'>". $data["Address"]." </td>"
echo "</tr>";
}
echo '</table>';
I also found a sql query that returns table1 row matching with table 2 Name field:
select Name, Firstname, Age, Address from data.table1 INNER JOIN data.table2 ON data.table1.Name = data.table2.Name;