将表的列名设置为文件名
这是我的代码,它正在创建名为"SELECT Name_of_company FROM companyinformation WHERE“$id”in my folder“的文件。
<?php
$con = mysqli_connect("127.0.0.1","root","","dbname");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
session_start();
$id=$_GET['id'];
$sql='
SELECT Name_of_company
FROM companyinformation
WHERE id="$id"
';
$result=mysqli_query($con,$sql);
$rows=mysqli_fetch_array($result);
echo $sql;
$createfile=$rows.".txt";
$email=$_SESSION['coll'];
$rnumber=$_SESSION['roll_number'];
$rollnumber="Roll Number \n";
$Email="Email Address ";
$newline="\n";
$rollema=$Email.$rollnumber;
$myfile = fopen($createfile, "a") or die("Unable to open file!");
fwrite($myfile, $email);
fwrite($myfile," ");
fwrite($myfile, $rnumber);
fwrite($myfile, $newline);
fclose($myfile);
//echo "<script>alert('Register Successfully');window.open('studentloginpage.php','_self');</script>";
?>
https://stackoverflow.com/questions/50649328
复制相似问题