I have a table in the bank that is called a toy, inside it I have the columns name, total, amount available and quantity donated. But I want to show only the name, the total and the total amount donated.
When I use the code below that I know is not what I have to use, it brings me everything but I have a repeated toy name on this table, and I wanted it to appear once, and the total came with the highest value and the amount donated of that toy already added.
if(isset($_REQUEST['rlanual']))
{
$ano1= $_REQUEST['rlanual'];
$res = $mysqli->query("select * from brinquedo where ano=$ano1");
$row1= $res->num_rows;
while($escrever = mysqli_fetch_array($res))
{
$nome1 = $escrever['nome'];
$total = $escrever['total'];
$qtd = $escrever['qtd_disponivel'];
echo "$nome1";
echo "$total";
echo "$qtd";
}
}
To get the highest total value I have this:
$sql1=$mysqli->query('SELECT MAX(total) FROM brinquedo');
$result1 = $sql1;
In short, I do not want the same toy to appear more than once. I've even tried string comparison and nothing.