Hiya - I have a mysql table that I am retreiving the data from. This is fine except that the result are simply formatted using:
print "<table border=\"1\" bordercolor=\"#CCCE64\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#EBEFB1\" width=\"550\">\n";
while($dataRow = mysql_fetch_row($query)) {
print "<tr>\n";
foreach($dataRow as $field)
print "<td>$field</td>\n";
print "</tr>\n";
}
print "</table>";
mysql_close($sqlConnect);
I would prefer to just display certain columns from the results though and I want to be able to give them formatting too. How would I go about doing this? I have used this code for formatting a .txt file... Is there a similar way to do the same thing?
$londonStationFile = "../activeData/".$londonStation.".txt";
$file = file($londonStationFile);
print"<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
while (list($key, $val) = each ($file)) {
$data = explode("|", $val);
print "<tr>\n\n";
printf("<td><h4>%s :: %s</h4> <!-- %s -->\n\n", $data[0], $data[1], $data[5]);
printf("%s", $data[2]);
printf("<p align=\"right\"><font size=\"-2\">%s</font> <img src=\"/images/londonRating%s.gif\" align=\"absmiddle\" width=\"70\" height=\"14\"></td>\n", $data[3], $data[4]);
print "</tr>\n";
}
print "</table>\n";
Any help appreciated...
🙂