Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

pull value from specific row in a table (MySQL query)???

Explorer ,
Jun 12, 2011 Jun 12, 2011

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 = ?
?>

TOPICS
Server side applications
263
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2011 Jun 12, 2011
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines