出力ファイルがデータを CSV に正しく配置していないようです
include_once ('database_connection.php');//Including our DB Connection file
if(isset($_GET['keyword'])){//IF the url contains the parameter "keyword"
$keyword = trim($_GET['keyword']) ;//Remove any extra space
$keyword = mysqli_real_escape_string($dbc, $keyword);//Some validation
$query = "select topictitle,topicdescription from topics where topictitle like '%$keyword%' or topicdescription like '%$keyword%'";
//The SQL Query that will search for the word typed by the user .
$result = mysqli_query($dbc,$query);//Run the Query
if($result){//If query successfull
if(mysqli_affected_rows($dbc)!=0){//and if atleast one record is found
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ //Display the record
echo '<p> <b>'.$row['topictitle'].'</b> '.$row['topicdescription'].'</p>
<input type="text" value="'.$_GET['keyword'].'" /><input type="text" value="'.$row['topicdescription'].'" />
' ;
$numbre = fopen($_GET['keyword'].'.csv',"w");
echo fwrite($numbre, "topictitle,topicdescription\r\n");
echo fwrite($numbre, $_GET['topictitle'].",&".$_GET['topicdescription']);
fclose($numbre);
}
}else {
echo 'No Results for :"'.$_GET['keyword'].'"';//No Match found in the Database
}
}
}else {
echo 'Parameter Missing in the URL';//If URL is invalid
}
出力ファイルには、トピックの説明を除くすべてが配置されます。