
Untitled
By: a guest on
Apr 23rd, 2012 | syntax:
None | size: 0.54 KB | hits: 8 | expires: Never
PHP MySql - How to extract specific records of a query result?
$myQuery = mysql_query(...);
while($row = mysql_fetch_assoc($myQuery)) {
???
}
$first_record = array();
while($row = mysql_fetch_assoc($myQuery)) {
if(count($first_record) == 0) {
$first_record = $row;
} else {
// not the first record
}
}
$array = array();
while ($row = mysql_fetch_assoc($query)) {
$array[] = $row;
}
$last = count($array);
echo $array[0]['username'];
echo $array[2]['username'];
echo $array[$last - 1]['username'];