I basically have been forced to learn SQL-programming from scratch to be able to complete a project I have been developing. With the help of the internet, and especially this site, I have been able to create a php-routine where I can choose data from my DB using drop downs. The results are then stored into a new table and what really bugs me is that I can`t wrap my head around how to display the results properly. What I am asking is how can I easily format the table so that the text is alligned as looks better on the eye?
I uploaded the file to this URL to show what my problem is: http://fantasysoccerpro.com/99.php
I want all four categories: POSITION, PLAYER, SALARY and PROJECTION to be alligned under each other on each line.
<?php
session_start();
$con = mysqli_connect("localhost",".....",".....",".....");
//or die ('unable to connect');
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//SHOW TEAM//
$sql = "SELECT * FROM 1dzzdp";
mysqli_select_db($con,'.....');
$retval = mysqli_query( $con, $sql );
if(! $retval )
{
die('Could not get data: ' . mysqli_error($con));
}
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC))
{
echo "{$row['POSITION']} ".
"{$row['PLAYER']} ".
"{$row['SALARY']} ".
"{$row['PROJECTION']}".
"{$row['SUM']} <br> ";
}
The simple answer is to wrap all that in a HTML table
echo '<table>';
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC))
{
echo '<tr>';
echo '<td>' . $row['POSITION'] . '</td>';
echo '<td>' . $row['PLAYER'] . '</td>';
echo '<td>' . $row['SALARY'] . '</td>';
echo '<td>' . $row['PROJECTION'] . '</td>';
echo '<td>' . $row['SUM'] . '</td>';
echo '</tr>';
}
echo '</table>';
Of course you may then need to do some formatting using some CSS.