Jump to content

writing to a file the result of a db


cowuser

Recommended Posts

ok ... the stupid cow is back again ...
Well... i have a table in the db that has usernames and websites... i want to write only the websites of a certain user to a file... i can view the results for the user for example 120 ( i get the user by ?user=120 ) but i can not put them i a file one in a row. How can i go on with that?
Link to comment
https://forums.phpfreaks.com/topic/4417-writing-to-a-file-the-result-of-a-db/
Share on other sites

You can use a loop like so:

[code]$query = mysql_query("SELECT website FROM users");
while($row = mysql_fetch_assoc($query)) {
    if($row['website']) {
        $ret = $ret . $row['website'] . "\n";
    }
}[/code]

When all is said and done, $ret will hold a variable with every website from the user table that had an entry (make the default website field NULL), put it in a file via whatever means you like, I don't think that was intended to be answered along with the above?

Of course, the mysql_query() will need changed unless I guessed correctly...
I am sorry, cow, I have been unable to respond to your posts on the forums because of some server error I have encountered. I have the solutions to all of your recent questions, but you may need to contact me via YIM/AIM at FireRescueNREMT. That is of course if this message even goes through.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.