Jump to content


Photo

writing to a file the result of a db


  • Please log in to reply
2 replies to this topic

#1 cowuser

cowuser
  • Members
  • Pip
  • Newbie
  • 3 posts
  • LocationAthens

Posted 08 March 2006 - 10:51 AM

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?

#2 k.soule

k.soule
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationIllinois

Posted 11 March 2006 - 03:06 AM

You can use a loop like so:

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

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

#3 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 11 March 2006 - 03:52 AM

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.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users