I'd like to put the data from a MySQL table in place (HTML Table). Everything is dynamic. Product names will not always be the same (columns). The number of records will not always be the same (rows).
MySQL Table (populate ROWS data)
iduser idprod quantity date
1234 65 60 2012-11-30 09:13:41.628
1234 66 50 2012-11-30 09:13:41.628
1234 64 80 2012-11-30 09:13:41.628
MySQL Table (populate COLUMNS data)
idprod name date
66 Panettone de Truffas 2012-11-29 15:19:41
65 Panettone de Maracujá 2012-11-29 15:16:56
64 Panettone de Brigadeiro 2012-11-29 15:16:44
Code
$panettones = array();
$querySel = "SELECT * FROM registro_panettone";
$resultSel = mysql_query($querySel);
$rows = mysql_num_rows($resultSel);
$panettones = array();
for($i=0;$i<$rows;$i++) {
/*$panettones["id_user"] = mysql_result($resultSel,$i,0);
$panettones["id_pan"] = mysql_result($resultSel,$i,1);
$panettones["qtd"] = mysql_result($resultSel,$i,2);
$panettones["data"] = mysql_result($resultSel,$i,3);*/
$retorno = mysql_fetch_array($resultSel);
$texto = "<tr>";
$texto .= "<td>".$retorno[0]."</td>";
$texto .= "<td>".$retorno[1]."</td>";
$texto .= "<td>".$retorno[2]."</td></tr>";
echo $texto;
}
Currently look like:
http://www.cacaushow.net.br/panettone_2012/rel.php
My wish is that it looks like:
http://www.cacaushow.net.br/panettone_2012/wish.php
Any suggestions?
PDO. It will make your life easier long term, also take into account thatmysql_commands are depricated. php.net/manual/en/mysqlinfo.api.choosing.php