Hello,
I need to make overview of a question list but somehow only 'fase2' is shown while there is data for fase1 but it loads in weirdly (see code bellow), fase2 but fase1 is shown up as a large empty array while fase2 does got data?
fase1 array dataif anyone got a clue what i am doing wrong please let me know because i cant figure it out.Code:Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( )
print_r($row); resultCode:echo '<table width="40%" align="center" id="vragenlijst"> <tr> <td width="50%">Vragen</td> <td width="10%" align="center">Fase 1</td> <td width="10%" align="center">Fase 2</td> <td width="10%" align="center">Fase 3</td> <td width="10%" align="center">Fase 4</td> </tr>'; foreach(fetchresults($naam, false) as $row){ if(!empty($row)){ print_r($row); //this does show fase1 and fase2 containing data $fase1 = array(); $fase2 = array(); $fase3 = array(); $fase4 = array(); if($row['fase'] == '1'){ $fase1 = explode(",", $row['antwoorden']); } elseif($row['fase'] == '2'){ fase2 = explode(",", $row['antwoorden']); } elseif($row['fase'] == '3'){ $fase3 = explode(",", $row['antwoorden']); }elseif($row['fase'] == '4'){ $fase4 = explode(",", $row['antwoorden']); } } else { echo "Geen resultaat."; $weergave = true; } } foreach(vragenlijst(2) as $vraag){ $newvraag = explode("=", $vraag); echo '<tr> <td width="10%" align="left">'.$newvraag[0].'</td> <td width="10%" align="center">'.$fase1[$i].'</td> <td width="10%" align="center">'.$fase2[$i].'</td> <td width="10%" align="center">'.$fase3[$i].'</td> <td width="10%" align="center">'.$fase4[$i].'</td> </tr>'; $i++; } echo '</table>';
if something is unclear please ask,Code:Array ( [id] => 2 [medewerker] => 1 [antwoorden] => 1=1,2=1,3=1,4=1,5=1,6=1,7=1,8=1,9=1,10=1,11=1,12=1,13=1,14=1,15=1,16=1,17=1,18=1,19=1,20=1,21=1,22=1,23=1,24=1,25=1,26=1,27=1,28=1,29=1,30=1,31=1,32=1,33=1,34=1,35=1,36=1,37=a,38=1,39=a [fase] => 1 [date] => 2020-04-14 10:02:18 ) Array ( [id] => 3 [medewerker] => 1 [antwoorden] => 1=1,2=1,3=1,4=1,5=1,6=1,7=1,8=1,9=1,10=1,11=1,12=a,13=a,14=1,15=1,16=1,17=1,18=1,19=1,20=1,21=1,22=1,23=1,24=1,25=a,26=a,27=1,28=1,29=1,30=1,31=1,32=1,33=1,34=1,35=1,36=1,37=1,38=1,39=1,40=1,41=a,42=1,43=a,44=1,45=1 [fase] => 2 [date] => 2020-04-14 10:04:15 )
thanks in advance.
- aristonia
'Coding is not just a hobby, its a sort of lifestyle'
I assume you mean "implode" rather than "explode". Implode is to convert an array to a string, explode is to convert a string to an array.
Returns:Code:$string = 'r,a,g,e,z,o,n,e'; $explodedString = explode(',', $string); print_r($explodedString);
Code:Array ( [0] => r [1] => a [2] => g [3] => e [4] => z [5] => o [6] => n [7] => e )Returns a string:Code:$array = ['r','a','g','e','z','o','n','e']; // According to PSR-2, you can use the brackets [] instead of array(). Only use array() if you plan on supporting a PHP version lower than 5.4 (which is really outdated). https://www.php-fig.org/psr/psr-2/ $implodedArray = implode(',', $array); print_r($implodedArray);
You can copy and paste my snippets in WriteCodeOnline - PHP | write and run php code online to test it yourself.Code:r,a,g,e,z,o,n,e
If you want $fase1 and $fase2 and such to be an array, you should only define the value of that variable as the value (result) of $row['antwoorden']:
Code:$fase1 = $row['antwoorden']
Forum Rules | Account Support | Subscribe
RaGEZONE Facebook
"The reason why people give up so fast is because they tend to look at how far they still have to go, instead of how far they have gotten."
Believe it or not but my script wasn't the issue; i was running OpenVPN and it messed up the $_SESSION which messed up everything.
topic can be closed.
'Coding is not just a hobby, its a sort of lifestyle'