How to bind data in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpfan
Forum Newbie
Posts: 14
Joined: Thu Aug 27, 2009 4:37 am

How to bind data in php

Post 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
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: How to bind data in php

Post 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
phpfan
Forum Newbie
Posts: 14
Joined: Thu Aug 27, 2009 4:37 am

Re: How to bind data in php

Post by phpfan »

ok thanks for the reply, any idea on how to bind the parsed data to drop down
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: How to bind data in php

Post 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>";
?>
 
Post Reply