此函数从数据库中获取记录。现在我希望它把它们写到一个文件中。请帮我。
function selectcsv($classname)
{
echo $sql = "SELECT * FROM tblstuden WHERE 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();
以上部分正在运行
$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);