Page 1 of 1

How to bind data in php

Posted: Tue Sep 29, 2009 7:46 am
by phpfan
Hi,

My task is, an excel file contains some records, where the first row has the headings and bellow that following are the corresponding records, in a form when the excel file is uploaded the fist row headings should be binded to the drop down list in the form, and when we click the drop down and select the elements, the selected element should appear in the text area.

i have searched in Google on how to bind data in php, but all in vain, kindly provide me solution

Re: How to bind data in php

Posted: Tue Sep 29, 2009 9:56 am
by Jade
Doesn't look like you searched very hard for this solution... there are sites with info on how to do this all over. You'll need to parse the file for the data then do whatever you need to with it, store it in a database or a file, whatever.

Try this link: http://www.ibm.com/developerworks/opens ... index.html

Re: How to bind data in php

Posted: Tue Sep 29, 2009 11:43 pm
by phpfan
ok thanks for the reply, any idea on how to bind the parsed data to drop down

Re: How to bind data in php

Posted: Wed Jan 20, 2010 2:24 pm
by Jade
If you've read the data into an array then all you need to do is iterate through the array and create a select box with the values of the array inside as the options.

Code: Select all

 
<?php
 
  echo "<select name=\"cell_" . $x . "_" . $y . "\">";
 
  foreach($array as $key => $value)
     echo "<option value=\"" . $key . "\">" . $value . "</option>";
 
  echo "</select>";
?>