I have tried my best to know about core difference b/w
mysql_fetch_row() and mysql_fetch_object()
and where these are suitable to use, but could not get.

Would you like to tell me.
Thanks in advance. 😕

    Have you read the PHP manual concerning [man]mysql_fetch_row/man and [man]mysql_fetch_object/man?

      [man]mysql_fetch_row[/man]
      [man]mysql_fetch_object[/man]

      mysql_fetch_row, as I understand, only fetches ONE row and reads it into an array. mysql_fetch_object reads the parts of tables selected into objects.

        Yes i have read the manual but in vain, i could not get difference b/w these. May i add one thing more.

        mysql_fetch_array();

        where these are suitable to use.
        Thanks.

        Merve wrote:

        [man]mysql_fetch_row[/man]
        [man]mysql_fetch_object[/man]

        mysql_fetch_row, as I understand, only fetches ONE row and reads it into an array. mysql_fetch_object reads the parts of tables selected into objects.

          In my experience level i will share this concept.

          mysql_fetch_row()

          The mysql_fetch_row will return the row of the fetched data as an array.

          For Example,

            $row=mysql_fetch_row($rs_data);

          will give $row[0] as the first filed of the fetched row and $row[1] will give the second field of the fetched row.

          mysql_fetch_array()

          The mysql_fetch_array will give the row of fetched row as array as like mysql_fetch_row. But the diff is we can use column name for fetching the result.

          $row=mysql_fetch_array($rs_data);

          Now we can access the row as
          $row[0] is same as $row[id] id as column name.

          mysql_fetch_object()

          The mysql_fetch_object as different from the above two.

          mysql_fetch_object will return the row as object.

          We can access as,

          $row=mysql_fetch_object($rs_data);

          The $row data can be accessed as,

          $row->id id ------- as column name.

          We can't access like $row[0] or $row[id] here.

          I think the above discussion will clear your doubt.

          Bye,

          With Love,

          Palanisamy KK
          PHP Programer.

            Write a Reply...