View Full Version : Recordset Question

01-15-2010, 08:07 PM
Hello Everyone, I am a bit new to php so bare with me :thumbsup:

So if I already have a generated record set how can I choose a specific row from that recordset. I need the rest of the recordset for another part of the page.

So if I wanted to echo $row_recordset['cost'] where $row_recordset['ID'] = 1 ... is there a really easy way to do this?


Thanks! :D

01-15-2010, 10:29 PM
Where is these records coming from? A file or a database?

If its a database you would need to do a mysql statement as follows :

$sql="SELECT * FROM table_name WHERE col1='$var1'";

echo $row['cost'];

Now in your case you would replace 'table_name' with the name of the table that you wish to extract the data from and col1 being the column in this table, in your case 'ID' i think and $var1 being what you wish to restrict it to, so you have stated '1'.

If its a file then you need to first access the file and then read the contents of the file.

Hope this helps!

01-19-2010, 09:58 PM
Thanks Killer - I will try this and let you know how it goes ! :thumbsup: