I'm running the below code to populate a HTML table using several calls to mysqli_query()
. The below snippet only shows three however I'm running ten in my file for various other date columns and may need more over time. I've attached a file below showing the basic database layout and required output.
The required output is basically just a list of times from various columns
The below code works fine, however it is probably not the most efficient and other options like MySQL JOIN
or UNION
don't seem to work.
Do we have any another options to perform the desired output?
$result = mysqli_query($con,"SELECT * FROM livescores WHERE actualstart >= '$datefilter'"); $resulthalf = mysqli_query($con,"SELECT * FROM livescores WHERE actualhalftime >= '$datefilter'"); $actualft = mysqli_query($con,"SELECT * FROM livescores WHERE actualft>= '$datefilter'"); while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['actualstart'] . "</td>"; echo "<td>" . $row['League'] . "</td>"; echo "<td>KO</td>"; echo "<td>" . $row['HomeTeam'] .' v '. $row['AwayTeam'] . "</td>"; echo "<td></td>"; echo "</tr>"; } while($row = mysqli_fetch_array($resulthalf)) { echo "<tr>"; echo "<td>" . $row['actualhalftime'] . "</td>"; echo "<td>" . $row['League'] . "</td>"; echo "<td>HT</td>"; echo "<td>" . $row['HomeTeam'] .' v '. $row['AwayTeam'] . "</td>"; echo "<td></td>"; echo "</tr>"; } while($row = mysqli_fetch_array($actualft)) { echo "<tr>"; echo "<td>" . $row['actualft'] . "</td>"; echo "<td>" . $row['League'] . "</td>"; echo "<td>FT</td>"; echo "<td>" . $row['HomeTeam'] .' v '. $row['AwayTeam'] . "</td>"; echo "<td></td>"; echo "</tr>";
Many Thanks
actualft
> the value in columnactualhalftime
> the value in columnstarttime
? and what are samples of values for$datefilter
- would it be like18:00
,19:30
, etc.?\$\endgroup\$