Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Recordset Question

    Hello Everyone, I am a bit new to php so bare with me

    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!

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    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 :

    PHP Code:
    $sql="SELECT * FROM table_name WHERE col1='$var1'";
    $result=mysql_query($sql);
    $row=mysql_fetch_Array($result);

    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!

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Killer - I will try this and let you know how it goes !


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •