php extract data from mysql
- by florin
I have this mysql table with the following rows:
id_cont suma_lun month year
--------------------------------------------
FL28 2133 March 2012
FL28 2144 April 2012
FL28 2155 May 2012
FL28 2166 June 2012
How can i extract suma_lun, month and year foreach id_cont? so that i get an output like this:
ID: Month: Monthly Sum: Year:
----------------------------------------------
FL28 March 2133 2012
April 2144 2012
May 2155 2012
June 2166 2012
This is my current code:
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) die ('Could not connect to database: '.mysql_error());
mysql_select_db(DB_DATABASE,$link);
$sql="SELECT * FROM test WHERE id_cont = '$cur'";
$result=mysql_query($sql);
while ($row=mysql_fetch_array($result)) {
$a=$row["id_cont"];
$b=$row["suma_lun"];
$c=$row["month"];
$d=$row["year"];
}
I echo the data in a table
Thanks!