-2
$info = array
(
    while($row = mysqli_fetch_array($retval, MYSQL_ASSOC))
    {
        array($row["id"],$row["name"],$row["mname"],$row["sdate"],$row["fdate"],$row["bphoto"],$row["sphoto"],
        $row["text"],$row["one"],$row["two"],$row["three"],$row["four"],$row["five"],$row["six"],$row["seven"],
        $row["eight"],$row["nine"],$row["imdb"],$row["sztrailer"],$row["etrailer"]),
    }
);  

Its Didn't worked. Please help me guys no i have more idea. (Sorry i have very bad english skill)

Parse error: syntax error, unexpected 'while' (T_WHILE), expecting ')' in .../Themes/default/sorozat.template.php on line 21

Thanks.

2 Answers2

0

Your code will not work. You can use this. First we make a array to store our values. After creating the array we store the values with a while loop. The key will be the id of your row

$info = array();
while($row = mysqli_fetch_array($retval, MYSQL_ASSOC)){    
    $info[$row["id"]]['name'] = $row["name"];
    $info[$row["id"]]['mname'] = $row["mname"];
    $info[$row["id"]]['sdate'] = $row["sdate"];
    $info[$row["id"]]['fdate'] = $row["fdate"];
    $info[$row["id"]]['bphoto'] = $row["bphoto"];
    $info[$row["id"]]['sphoto'] = $row["sphoto"];
    $info[$row["id"]]['text'] = $row["text"];
    $info[$row["id"]]['one'] = $row["one"];
    $info[$row["id"]]['two'] = $row["two"];
    $info[$row["id"]]['three'] = $row["three"];
    $info[$row["id"]]['four'] = $row["four"];
    $info[$row["id"]]['five'] = $row["five"];
    $info[$row["id"]]['six'] = $row["six"];
    $info[$row["id"]]['seven'] = $row["seven"];
    $info[$row["id"]]['eight'] = $row["eight"];
    $info[$row["id"]]['nine'] = $row["nine"];
    $info[$row["id"]]['imdb'] = $row["imdb"];
    $info[$row["id"]]['sztrailer'] = $row["sztrailer"];
    $info[$row["id"]]['etrailer'] = $row["etrailer"];
}

print_r($info);
Rafael Shkembi
  • 786
  • 6
  • 16
0

First of all, this looks really ugly. You gotta provide a better readability to your code.

Secondly, you should declare the $info array first instead of looping within the array itself.

Try this:

$info = array();

while($row = mysqli_fetch_array($retval, MYSQL_ASSOC))  {
        $info[] =   array(
               $row["id"], $row["name"], $row["mname"],
               $row["sdate"],$row["fdate"], $row["bphoto"], 
               $row["sphoto"], $row["text"], $row["one"],
               $row["two"], $row["three"], $row["four"],
               $row["five"], $row["six"], $row["seven"],
               $row["eight"],$row["nine"],$row["imdb"],
               $row["sztrailer"],$row["etrailer"]
           );
}
Indrasis Datta
  • 8,692
  • 2
  • 14
  • 32