There is a database and a table. It contains many meanings.
I need to output all table values in json format and another additional condition, if the rows are the same (but the cost parameter is different, then output the largest of them).
Here is my code.
mysql_connect($sdd_db_host,$sdd_db_user,$sdd_db_pass) or die(mysql_error()); mysql_select_db($sdd_db_name) or die(mysql_error()); mysql_set_charset('utf8'); $date = array(); $row = mysql_query("SELECT sh,name,ed,MAX(cost) AS cost FROM 'datatable'"); while($row = mysql_fetch_assoc($row){ $data[] = $row; } echo json_encode($data); ?>
What is the problem?