Results 1 to 3 of 3

Thread: [RESOLVED]Write function to get all records?

Threaded View

  1. #1

    Thread Starter
    Lively Member rasana's Avatar
    Join Date
    Jan 2007
    Location
    Mumbai, (India)
    Posts
    94

    Resolved [RESOLVED]Write function to get all records?

    Hi All,

    I'm working on a project where I have to write a function to get all records from a table which will return array of objects.
    I've written a function to get a single record from table and working fine..but to get all records i'll have to write while loop..how would I store data in array and how would I display all data...?

    Below is function to get a single record


    PHP Code:
    $sql "select * from student where id = 1";
    $getData $db->getRecord($sql);

    function 
    getRecord($sql)
        {
            
    $result mysql_query($sql) or die(mysql_error());
            
    $data_set mysql_fetch_array($result);
                
        return 
    $data_set;
        } 
    Last edited by rasana; Nov 6th, 2008 at 06:32 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width