I am trying to find out MAX ref number value of a column from a ledger table, where company are being selected from insurers table. It is working perfect.
But i need your comments on this query. Any other shorter way to do this?

PHP Code:
$query "SELECT insurers FROM insurers";
$result mysql_query$query );
    if (!
$result){
    die (
"Could not query the database: <br />"mysql_error( ));
    }
    echo 
'<table border=1> <tr>';
    
$i 0;
    while (
$ins mysql_fetch_array($result)) 
    {
    
$i++;
        
$query1 'SELECT MAX(ref_no) FROM ledger WHERE insurers="' $ins['insurers'] . '"';        
        
$result1 mysql_query$query1 );
            if (!
$result1)
            {
            die (
"Could not query the database: <br />"mysql_error( ));
            }
                while(
$in mysql_fetch_array($result1))
                {
                echo 
'<td>'    $i '</td><td> Recent Ref # in <i> ' $ins["insurers"] . '</i></td><td>' $in[0] . '</td></tr>';
                }
    }
    echo 
'</table>'