SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Use of 'expand' command

    In my database, I need to get all of the database fields into variables. I do this using the expand command, like this:

    PHP Code:
    $result mysql_query("select Product_Type, Product_Name FROM products where Product_ID=$pid"); 

    extract(mysql_fetch_array($result)); 
    This command seems to easy to me... is it inefficent, or bad in anyway?
    Regards, Ant.

  2. #2
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could also just use the array that mysql_fetch_array() creates by doing something like
    PHP Code:
    $row mysql_fetch_array($sql); 
    then you can use $row['column_name'] in your code.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  3. #3
    SitePoint Addict eddiembabaali's Avatar
    Join Date
    Mar 2001
    Location
    USA, Philadelphia
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is another cool way to extract array values... The first time I saw it too I was like "WOW PHP sure rocks !!"
    cd pub \r; more beer

    Eddie


Bookmarks

Posting Permissions

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