I want to make the style parse from the information given in the query.
I have the bgcolor & text color that I want displayed listed in my table, and I have tested the MySQL query and it runs fine, but I've tried to get it to run here but it does not provide me with what I need.
The way I tried was this:
<?php
include('SQLFunctions.php');
$q = $_POST["q"];
$link = f_sqlConnect();
$ATColor = 'SELECT M.ATeam, T.bgcolor,T.txtcolor
FROM matches M LEFT JOIN teams T ON M.ATeam=T.TeamID WHERE MatchID = '.$q;
if($result = mysqli_query($link,$ATColor)) {
while ($row = mysqli_fetch_array($result)) {
echo "<th colspan='2' style='background-color:{$row[1]};color:{$row[2]}'><p>$ATeam</th>"; }
} else {
echo "<th colspan='2'><p>$ATeam</p></th>";
}
On this I get the false side displayed, It clearly is an issue with the first 2 lines of the if statement, but I can't see the issue. The $link is a global string and works everywhere else, so it's not that.
Appreciate someone pointing out somethings that's probably easy & obvious.
UPDATE:
After lots of testing it's certainly to do with the if statement, but I cannot see the issue.
So I have no idea why, there are no errors on the page (I have error reporting on) and the code loos fine.
These two lines are somehow the issue, please help, it's driving me crazy:
if($result = mysqli_query($link,$ATColor)) {
while ($row = mysqli_fetch_array($result)) {