php - get first and last value form a mysql results array -


how go getting first , last value sql query . want highest , lowest vaue of variable $integer1, have ordered them in ascending order in sql query, need pull them out of array first , last items. tried didn't work:

$first = reset($result); $last = end($result); 

also, in sql query select string1, string2 , integer1

i want order integer1 , print out first , last (both strings)

 first   echo $string 1. " " . /4string2;  last   echo $string 1. " " . /4string2; 

asuming want min , max value of field in sql.

instead of fetching rows table , take first , last row in php, in sql !

select min(your_field), max(your_field) your_table conditions group field1,field2 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -