I am trying to do the following… select all columns from the table hqfjt_chronoforms_data_addemailtemplate, then echo the data from each record, from the columns emailformname and emailformmessage. I am using the following code but am getting a bunch of errors, I am just learning php so it is probably a bit wrong :-S .
<?php
$query = mysql_query("SELECT * FROM hqfjt_chronoforms_data_addemailtemplate") or die(mysql_error());
foreach($query as $detail) {
echo $emailarray->emailformname;
echo $emailarray->emailformmessage;
}
?>
As mentioned, it is probably better to learn PDO for those just learning. It is more secure, more information and a tutorial can be found here:
http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/
If you want to use objects with a mysql query, something like this will allow you to do so:
http://php.net/manual/en/function.mysql-fetch-object.php
If you would like to do what Frits mentioned, then something like this will achieve your result:
http://php.net/manual/en/function.mysql-fetch-assoc.php
There is also arrays as an alternative:
http://php.net/manual/en/function.mysql-fetch-array.php