<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error
connecting to mysql');
mysql_select_db($dbname);
$query = "SELECT name,type,MIN(totalprice) FROM transactions GROUP
BY name,type";
$result = mysql_query($query) or die(mysql_error());
$data = '';
while ($row = mysql_fetch_array($result) {
$data .= 'Name: ' . $row['name'] . ', Type: ' . $row['type'] . "
";
}
$myFile = "testFile.txt";
file_put_contents($myFile, $data, FILE_APPEND);
?>
Based on your codes righht? If I want to like display this
Example this is my highest data: (Meaning that this is what I
want to add as static)
43 (Meaning that this is my SQL codes which the values are
dynamic)
How can I actually do it based on the codes (Static)
I don't get your question. Do you mean the text to be written
into the file is hardcoded in the PHP code instead of being pulled
out from a MySQL database? In that case, the code will simply
be:
<?php
$text = 'New Stuff 123';
$myFile = "testFile.txt";
// the line below writes the value in $text into the file
specified in $myFile
// if the file already exists, it will NOT overwrite the file, but
instead append the text to the end of the file
file_put_contents($myFile, $text, FILE_APPEND);
?>