Making a HTML table based on SQL data in PHP -


i trying make dynamic html table php, populating data mysql database. far have tried while loop, result ends in displaying same first row gets multiple times.

<div class = "container">         <p>registered companies:</p>         <table border = "1px" align = "left">             <tr>                 <th>username</th>                 <th>company name</th>                 <th>company value1</th>                 <th>company value2</th>             </tr>             <?php                 $comprowincrement = 0;                 while ($comprowincrement < $companyrowcount) {             ?>                     <tr>                         <td><?php echo $companyrow['user_name']?></td>                         <td><?php echo $companyrow['company_name']?></td>                         <td><?php echo $companyrow['company_value1']?></td>                         <td><?php echo $companyrow['company_value2']?></td>                     </tr>             <?php                     $comprowincrement++;                 }             ?>         </table>     </div> 

it should display 3 rows of data example (sql query returns 3 different values). far have achieved 3 rows (like need) same data (first value gets database).

how do each table row populated different data, in database.

i'm learning, if don't mind ignore css values in table :).

edit1 (added query)//

$getplayercompanies = $mysqli_con -> query("select distinct *                                               companies                                               left join player on companies.player_id = player.player_id                                               left join users on users.user_id = player.user_id                                               users.user_id =".$_session['usersession']); $companyrow = $getplayercompanies -> fetch_array(); $companyrowcount = $getplayercompanies -> num_rows; 

following query returns 3 rows, should.

where did $companyrow values populated?

i belive code should more (or mysqli commands)

<?php      while ($companyrow = $getplayercompanies -> fetch_array() )       { ?>          <tr>              <td><?php echo $companyrow['user_name']?></td>              ...          </tr> <?php       } ?> 

Comments