1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How i can make a while in a array?

Discussion in 'PHP & Perl' started by knaller1, Aug 21, 2015.

  1. knaller1

    knaller1 Registered Member

    Joined:
    Oct 30, 2013
    Messages:
    63
    Likes Received:
    4
    Hey,

    so i have a problem i want to execute a script like that.

    PHP:
    $updateArticle = array(   'configuratorSet' => array(        'groups' => array(
                array(                
    'name' => 'Farbe',                'options' => array(

    // HERE IS THE PROBLEM

                    
    if ($resultatfarben $db->query('SELECT * FROM cache_article WHERE artikelnummer = '.$herstellnummer.' GROUP BY farben')) {                  while($datenfarben $resultatfarben->fetch_object() ){                array('name' => ''.$datenfarben->farbe.''),
                      }                  }
    // PROBLEM END


                    
    )            ),...
    I market the Error Code in the Text. How i can do the same result but so its work?
    But i need the result of this like

    PHP:
    array('name' => "Green"),
    array(
    'name' => "Blue"),
    array(
    'name' => "Yellow"),
    How i can do that?
    I hope you understand... my english is very bad.


    Thank You
     
  2. nocare

    nocare Junior Member

    Joined:
    Apr 29, 2013
    Messages:
    164
    Likes Received:
    81
    Location:
    Deep Code
    Code:
    $array = [];
    while($row = $dbHandle->fetch_object()) {
        $array[] = ['name' => $row->name];
    }
    
     
  3. iamian

    iamian Newbie

    Joined:
    Jun 5, 2015
    Messages:
    4
    Likes Received:
    0
    just try that. cmiiw. :)