so im trying to query a postgres database that will return multiple rows. this is just an example of what im wanting to do, not real. say i have a database called employees. i have 10 employee records and each record contains the first name, last name, and age. the data will be returned to me from the database as 10 rows with the first name, last name, and age if i were to select * from *;.
now for the tricky part. i want php to assign a variable name to the results, first name = $first_name or whatever, but i want each row's first name to be a different variable. IE, i want to be able to print $first_name1 or something like that to print the first name of the first row and $first_name2 to print for the first name of the second row and so forth for all of the variables, so 10 first names, 10 last names, 10 ages.
basically, i need to take all the data that has been returned and do some math with them to get some totals and whatnot, it is long and drawn out. the script im using on single row databases "works" but i get one rows values for all rows since the variables are getting overwritten each time it sees a new row.
how do i do that? im thinking an array will do it but i tried reading about them and just got lost. im not that great with php and just need the basic code so i can morph it into a script that can handle this database. if anything in this post isnt clear or doesnt make sense, let me know and i'll try to explain further.