I have a table data and a few columns and I am trying to display the values of certain columns only. I wrote this below code but it is not working correctly. giving some error.
$daily = mysql_query("SELECT email, first_name, last_name AS dval FROM users");
while( $stat = mysql_fetch_assoc($daily))
{
echo '<br/>' . " {$stat['dval']}";
}
Only the first_name of all the entries is being printed. How can I get the email and last name?
You need to execute the query with
mysql_query():I changed your variable names to use the common naming convention.
To get more than one row to print, use a
whileloop:Note that the mysql_* functions are being deprecated, and you should switch to either
mysqliorPDO.Why would anything but
$stat['dval']print? You only saidecho $stat['dval'];.Add the things you want to print in the
whileloop: