Note that there are some explanatory texts on larger screens.

plurals
  1. POget values from $rowData
    primarykey
    data
    text
    <p>I`m trying to make a simple page in php where data from an excel sheet is displayed.</p> <p>I have gone through this <a href="https://stackoverflow.com/questions/9695695/how-to-use-phpexcel-to-read-data-and-insert-into-database">link</a>.</p> <p>when I use foreach loop to print the values of $rowData I get only one value printed. My Excel Document consists of 2 Columns Attendance and register number only the first value is displayed.</p> <p>here`s teh foreach am using</p> <pre><code>foreach($rowData as $row){ foreach($row as $var){ echo "{$var}&lt;br/&gt;"; } } </code></pre> <p>I searched for information regarding rangeToArray method but am not able to get information regarding what parameters are passed to it.Please can someone explain how the method works..</p> <p>Edit: output when print_r used </p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; Register Number [1] =&gt; Attendance ) ) Array ( [0] =&gt; Array ( [0] =&gt; UR11CS012 [1] =&gt; 0.78 ) ) Array ( [0] =&gt; Array ( [0] =&gt; UR11CS013 [1] =&gt; 0.65 ) ) Array ( [0] =&gt; Array ( [0] =&gt; UR11CS015 [1] =&gt; 0.67 ) ) </code></pre> <p>Edit: here is the code still printing last value only whats wrong ? should i have saved file in a seaprate folder <strike>uploaded file</strike> rather than use it from the temporary folder</p> <pre><code>&lt;?php $name=$_FILES['u_file']['tmp_name']; try { $inputFileType = PHPExcel_IOFactory::identify($name); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader-&gt;load($name); } catch(Exception $e) { die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e-&gt;getMessage()); } $sheet = $objPHPExcel-&gt;getSheet(0); $highestRow = $sheet-&gt;getHighestRow(); $highestColumn = $sheet-&gt;getHighestColumn(); for ($row = 1; $row &lt;= $highestRow; $row++){ $rowData = $sheet-&gt;rangeToArray('A' . $row . ':' . $highestColumn . $row,NULL,TRUE,FALSE); } print_r($rowData); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload