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
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...
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.