Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5941419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:06:26+00:00 2026-05-22T16:06:26+00:00

As you can see below I am pulling information from a database and writting

  • 0

As you can see below I am pulling information from a database and writting it to a text file in a structured format (Thanks to everyone who has helped me out).

// Query the database for data
$query = "SELECT cards.card_id,title,description,meta_description,seo_keywords,price FROM cards,card_cheapest WHERE cards.card_id = card_cheapest.card_id ORDER BY card_id";
$result = mysql_query($query);

$result = mysql_query($query);

// Open file for writing
$myFile = "googleproducts.txt";
$fh = fopen($myFile, 'w') or die("can't open file");

// Loop through returned data and write (append) directly to file
fprintf($fh, "%-10s %-50s  %-450s   %-50s %-300s\n", "id", "label","description","price","seo keywords");
fprintf($fh, "\n");
while ($row = mysql_fetch_assoc($result)) {
 fprintf($fh, "%-10s  %-50s  %-450s  %-50s  %-300s\n", $row['card_id'], $row['title'], $row['description'],$row['price'], $row['seo_keywords']);
}

// Close out the file
fclose($fh);
?>

There are a few things that need to be added in it’s separate column that is not in the database. Mainly just bit of text like “bob’s cards” . I was wondering if it is possible to add that into the mix and have it loop through. Or is it just simpler to add it to the database?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:06:27+00:00Added an answer on May 22, 2026 at 4:06 pm

    You can have MySQL write the data directly to a file using

    SELECT cards.card_id
      ,title
      ,description
      ,meta_description
      ,seo_keywords
      ,price 
    INTO OUTFILE 'c:/dir/test.txt' FIELDS ESCAPED BY ' ' FIELD ENCLOSED BY '"' 
    FROM cards
    INNER JOIN card_cheapest ON (cards.card_id = card_cheapest.card_id) 
    ORDER BY card_id 
    

    !! Note the use of forward slashes even on Windows !!

    And please replace that ugly implicit WHERE join by an explicit INNER JOIN; it will make future alterations to that query much easier to debug.

    Links: http://dev.mysql.com/doc/refman/5.1/en/select.html
    And for the options to SELECT .. INTO OUTFILE see: http://dev.mysql.com/doc/refman/5.1/en/load-data.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a pretty complicated form. as you can see below: alt text http://img9.imageshack.us/img9/2465/test2xk.jpg
I have one text input and one button (see below). How can I use
I have some really funky code. As you can see from the code below
As you can see below, in the constructor I'm instantiating a validation object so
I'm using graphviz (dot) to generate the graph you can see below. The node
Trying not to lose it here. As you can see below I have assigned
I have a SOAP message (see below). Using Xpath, how can I extract the
I have this code below. As you can see I am passing two variables
Can't seem to figure this out, see code below. Trying to make a GET
I tried command like below. But can't see server time. psexec \\SERVER_NAME -i -u

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.