Jump to content

Creating a nested while loop to return multiple dropdowns


pagegen

Recommended Posts

Am trying to write a nested while loop which will create 5 drop down lists all with the same options but the code below is only creating 1 drop down list with the options and the rest are all empty lists.. any suggestions

<?php

$numberOfRows = 1;

$row = 1;
$t=1;
do {
$handle = fopen("vicidial_temp_file.csv", "r");
echo "<select name='$numberOfRows'>";
	while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) 
	{
		if ($row <2)
  				{
    				$num = count($data);
    				$row++;
    				for ($c=0; $c < $num; $c++) 
    				{
        			echo "<option value='$data[$c]'>$data[$c]</option>";
             		}
   				}
	}
		fclose($handle);
	   	echo '</select>';
   			echo $t;
   			$numberOfRows ++;
   			$t = $t + 1;
} while($t <= 5);


fclose($handle);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.