khaleel_rashid 0 Newbie Poster

I just want to create a max function in php. in this function i have to just write the table name and the columns name where i want to call the function and get the max values from the corresponding column of that table


PHP Code:

function max1($column_name, $table_name) 

{ 

    $query= "select MAX('$column_name') as max_column from $table_name"; 
    $result= mysql_query($query) or die(mysql_error()); 

        while ($row = mysql_fetch_array($result)) 
    { 
         
     return $row['max_column']; 
         
    } 
} 

$t = max1("admit_id", "tbl_admit_room"); 
echo $t;