Results 1 to 2 of 2

Thread: how return a field name with the value in a mysql quer?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    97

    how return a field name with the value in a mysql quer?

    hi,
    i need get the name of the field by a query
    for example

    if a do this:

    $res = mysql_query( "select * from total )
    $v1=mysql_fetch_row_name($res);
    while($v1=mysql_fetch_row($res)) {

    echo $v1[0]; // return the value of field number 0

    }

    but i need to know also this:


    echo "the field name xxx have this record ". $v1[0];

    in vb we have the objects that return the name and the value and all information of the field but how can i see this in php?
    thanks a lot for your help

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: how return a field name with the value in a mysql quer?

    PHP Code:
    while($arr mysql_fetch_array($query)){
      
    //dump fields
      
    $fields = array();
      
    $j 1;
      foreach(
    $arr as $key => $value){
        
    $j++;
        if(
    $j 2){ //result returns numerical and string keys, we're only interested in strings
          
    $fields[] = $key;
        }
      }


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