write a file in php -


this function fetches records db. want write them file. please me.

function selectcsv($classname)     {         echo $sql = "select * tblstuden classname = $classname;";          $obj_db = new db();         $obj_db->query($sql);          while($row = $obj_db->rsset()){         $this->_id($row[id]);         $this->_studentname($row[studentname]);         $this->_rollnumber($row[rollnumber]);         $this->_classname($row[classname]);          $out = $out . $row[studentname] . " , ". $row[rollnumber] . "\n";         }          $obj_db->db_close(); 

the above portion running

$myfile = "write.txt"; $fh = fopen($myfile, 'w') or die("can't open file"); $stringdata = "write::"; fwrite($fh, $stringdata); $stringdata = $_post[read]; fwrite($fh, $stringdata); fclose($fh); 

you never write $out data file.

instead of:

$stringdata = "write::"; fwrite($fh, $stringdata); $stringdata = $_post[read]; fwrite($fh, $stringdata); 

you should:

fwrite($fh, $out); 

you should try read , understand php manual page fwrite.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -