CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    141

    mysqli retrieve unspecified amount of fields

    hi

    i faced this problem since yesterday and I still haven't got the right solution yet

    to cut it short, here's my preparedstatement query

    Code:
    $query = "select * from ingredients where id=? and language=?";
    $stmt = $dbi->prepare($query);
    $stmt->bind_param('ss', $ID,$language); 
    $stmt->execute();
    the table has the field name that starts with ingredients1, ingredients2,quantity1,quantity2 and so on until ingredients50 and quantity50.

    my problem is how do I read all those returned fields? I need the returned fields to be set to its respective variable name, for example the field ingredients1 assigned to variable $ingredients1 and so on?

    i tried the solution at http://forums.devshed.com/php-develo...ay-568982.html but still can't get it working as I want it

    any help is greatly appreciated! thanks!

  2. #2
    Join Date
    Jul 2005
    Posts
    141

    Re: mysqli retrieve unspecified amount of fields

    no one understand my prob?

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: mysqli retrieve unspecified amount of fields

    Learn patience. It hasn't even been 12 hours. Not everyone who helps out here checks in every day.

    Concerning your problem, if you convert your result to an array, you can use PHP's extract() function to convert them to respective variable names.

    EDIT: Also, if you are using a SELECT command, you shouldn't be using a prepared statement, but instead perform a simple query.
    Last edited by PeejAvery; January 22nd, 2009 at 11:54 AM.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    Jul 2005
    Posts
    141

    Re: mysqli retrieve unspecified amount of fields

    Quote Originally Posted by PeejAvery View Post
    Learn patience. It hasn't even been 12 hours. Not everyone who helps out here checks in every day.

    Concerning your problem, if you convert your result to an array, you can use PHP's extract() function to convert them to respective variable names.

    EDIT: Also, if you are using a SELECT command, you shouldn't be using a prepared statement, but instead perform a simple query.
    ouh..thanks... simple select should be OK it seems..

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

Featured