Are there anyone who is clever at php used to extract data from a mysql database and place it into a webpage.
Actually I am ok extracting from a database but I have run into a problem and cannot figure out how to solve it.
The date stored in the database is in the format yyy-mm-dd I want to convert it to the UK format of dd-mm-yyy.
Below is the php I am using to extract the info but I have tried a couple of but the conversion doesn't work.
<?php
// ------------------------ database connection
// VARS for connection
$vDBHost = "localhost";
$vDBUser = "*********";
$vDBPass = "*********";
$vDBName = "**********";
// Open Db Connection
function OpenDB()
{
global $vDBHost;
global $vDBUser;
global $vDBPass;
global $vDBName;
// Connect to server
$con = mysql_connect("$vDBHost","$vDBUser","$vDBPass");
if(!$con)
{
echo mysql_errno() . ": " . mysql_error() . "<br>\n";
echo "Could not connect to database server!<br>\n";
exit;
}
if(!mysql_select_db($vDBName, $con))
{
echo mysql_errno() . ": " . mysql_error() . "<br>\n";
echo "Could not connect to database!<br>\n";
exit;
}
return $con;
}
// Connect to DB
$dbcon = OpenDB();
// -------------------------- fetch data
echo "<table width=\"850\" align=\"center\">";
echo "<tr><th>Date</th><th></th><th>Name</th><th>Scooter</th><th>Class</th><th>Event</th><th>Speed</th></tr>";
// select all the records
$result = mysql_query("SELECT * FROM speeds WHERE Reg='Y' AND speed > 0.0 ORDER BY speed DESC",$dbcon);
// for each record found - while loop
while ($arow = mysql_fetch_array($result)) {
// load to vairables
$field1 = $arow["created_at"];
$field2 = $arow["Country"];
$field3 = $arow["Name"];
$field4 = $arow["Scooter"];
$field5 = $arow["Class"];
$field6 = $arow["Event"];
$field7 = $arow["Speed"];
$field8 = $arow["Reg"];
// -------------------------- display data
// output rows
echo "<tr><td>$field1</td><td>$field2</td><td>$field3</td><td>$field4</td><td>$field5</td><td>$field6</td><td align='right'>$field7</td>";
} // end while loop
echo "</table>";
?>
I think there is a function I need to add to above but I can't figure it out. Click the link to see the page the info is on and you will see a couple of the date entries formatted in US format and not UK format as I would like. Doesn't matter about the rest of the dates, I can edit those in the database later
http://www.100mphscooter.com/speeds2.html
Thanks in advance to anyone that can help.
---------------------------