Copy link to clipboard
Copied
i'm having a problem with something that i feel should be fairly easy to do. say i had the following query that creates a list of names and ages of people in the state of texas (sorted alphabetically):
<?php
mysql_select_db($database_somedatabase, $somedatabase);
$query_findPeople_rs = "SELECT firstname, age FROM people WHERE state = 'texas' ORDER BY firstname ASC";
$findPeople_rs = mysql_query($query_findPeople_rs, $thesilentcritic) or die(mysql_error());
$row_findPeople_rs = mysql_fetch_assoc($findPeople_rs);
$totalRows_findPeople_rs = mysql_num_rows($findPeople_rs);
?>
So let's say this pulls the following entries (assume all are from texas):
Adam 32
Bob 28
Dave 29
Jim 43
Jim 26
Mike 30
Phil 54
Steve 22
Steve 36
i check the number of rows by:
<?php
$counter = mysql_num_rows($findPeople);
?>
This would set $counter to the number 9.
Now my question is, how would i store the first name of the person in the 9th row (Steve) as the variable $name
<?php
$name = ?
?>
Copy link to clipboard
Copied
nevermind. i got an answer from another forum. i ended up just creating a new query in which I did ORDER BY firstname DESC LIMIT. that gave me the last entry.