Well, I'm gathering some info from my db with a query and then outputting the results to a file. I have successfully gathered all of the information for the files and printed the info to them, the only problem is that it just kind of bunches it all together. I need to seperate each result on its own line and even include two of the results on the same line with an "=" between the two of them. If someone can generally guide me on how to format the text output, it would be very helpful.
Here is a snipit of the code i'm currently using:
$sql = "SELECT
c.components_name,
s.subsection_name,
psk.key_name,
ps.parameter_settings_value,
psk.key_description
FROM
parameter_settings ps
INNER JOIN
components c
ON
ps.components_id = c.components_id
INNER JOIN
subsections s
ON
ps.subsection_id = s.subsection_id
INNER JOIN
parameter_settings_key psk
ON
ps.key_id = psk.key_id
WHERE
ps.configuration_id = $configuration_name AND ps.components_id = $value";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
foreach ($row as $fileValue){
print "$fileValue<br>";
fputs($fp, $fileValue);
}
}
fclose($fp); //closes the file being written to
Thanks to all in advance!
Chris
formatting the text that's saved to a file in PHP
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Code: Select all
while ($row = mysql_fetch_assoc($result)){
foreach ($row as $fileValue){
print "$fileValue<br>";
fputs($fp, "".$fileValue."\r\n");
}
}-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
psiege : viewtopic.php?t=21171