Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Create table with php from mysql table

$
0
0

Hi,

 

I'm really a noob with php, hopefully you can put me in to the right direction.

I have a MySQL stored procedure which gives for an example the following output:

 

seasonID  |  Name | Points |  EventID

20             |  Ron   |    10    |     1

20             |  Ron   |     0     |     2

20             |  John  |     5     |     1

20             | John   |     8     |     2

 

I want to display the results in a table so it would look like this:

 

Name       |   EventID 1 |  EventID 2 | Total Points

John         |       5           |      8           |      13

Ron          |      10          |      0           |      10

 

So for every new EventID within a season there should be a new column.

 

To be honest I don't know where to start, all I get is the same output from the stored procedure.

Every row in MySQL is also a new row in php.

 

This is what I have:

<table border="0" cellspacing="0" dellpadding="2">
        <?php        if($seasonId != "50")
        {         $DriverPoints = mysqli_query(getConnection(), "CALL sp_ron('$seasonId')");
                  {          $pos = 1;

          while($rowDriverPoints = mysqli_fetch_object($DriverPoints))
                    {   echo("<tr><td width='30' align='center' class='property'>" . $rowDriverPoints->name . "</td>
             		<td width='30' align='center' class='property'>" . $rowDriverPoints->eventname . "</td>
		        <td width='30' align='center' class='property'>" . $rowDriverPoints->points . "</td></tr>");
           		$pos++;
		    }        
	      	  } 
       }        
?>
</table>

Viewing all articles
Browse latest Browse all 13200

Trending Articles