Jump to content

rseigel

Members
  • Posts

    88
  • Joined

  • Last visited

rseigel's Achievements

Member

Member (2/5)

1

Reputation

  1. LOL....I guess I figured it couldn't possibly be that easy. Turns out it was..... Thanks.
  2. One last thing and this code is complete. I'm trying to add a header above the field names in the csv. $result = mysqli_query($con,"SELECT * FROM amazon"); $num_fields = mysqli_num_fields($result); $headers = array(); for ($i = 0; $i < $num_fields; $i++) { $headers[] = mysqli_fetch_field_direct($result, $i)->name; } $fp = fopen('amazon.csv', 'w'); if ($fp && $result) { $list = array ( array('TemplateType=Offer', 'Version=2014.0703') ); foreach ($list as $fields) { fputcsv($fp, $fields); } fputcsv($fp, $headers, "\t"); while ($row = mysqli_fetch_row($result)) { fputcsv($fp, array_values($row), "\t"); } } Problem is I need a Tab separating the fields - not a comma. So: array('TemplateType=Offer', 'Version=2014.0703') needs to be something else. Maybe I'm overcomplicating this? Any ideas? Thanks Ron
  3. PERFECT! Thank you! Here's the updated code. I needed it to be tab delimited so I added that as well. $result = mysqli_query($con,"SELECT * FROM amazon"); $num_fields = mysqli_num_fields($result); $headers = array(); for ($i = 0; $i < $num_fields; $i++) { $headers[] = mysqli_fetch_field_direct($result, $i)->name; } $fp = fopen('amazon.csv', 'w'); if ($fp && $result) { fputcsv($fp, $headers, "\t"); while ($row = mysqli_fetch_row($result)) { fputcsv($fp, array_values($row), "\t"); } }
  4. AHHHHHHHHHH..... False alarm. Doesn't work after all. I'll create a new thread to try to figure out how to make this work.
  5. Just to complete this... Here's the code I used to create the csv file: $result = mysqli_query($con,"SELECT * FROM amazon'"); $num_fields = mysqli_num_fields($result); $headers = array(); for ($i = 0; $i < $num_fields; $i++) { $headers[] = mysqli_fetch_field_direct($result, $i)->name; } $fp = fopen('php://output', 'w'); if ($fp && $result) { header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="amazon.csv"'); header('Pragma: no-cache'); header('Expires: 0'); fputcsv($fp, $headers); while ($row = mysqli_fetch_row($result)) { fputcsv($fp, array_values($row)); } } No idea if this is the correct way to do it or not but it works. Off to the next adventure.....
  6. Yup...my host won't touch this one. Time for plan B....
  7. I take it back.... There's no FILES option in my hosting. I've emailed my host to see what they can do about this.... Thanks, Ron
  8. Thanks for the tip in #2. Much appreciated. After that change all is exactly as you have stated. It still doesn't create the file.
  9. I'm trying to run the following: mysqli_query($con,"SELECT * FROM amazon INTO OUTFILE 'amazon.csv'"); It's running from a php file in the root directory. Not sure why it won't create the csv file. Any ideas? Thanks, Ron
  10. rseigel

    JOIN Issues

    Thanks very much. That works. I have other issues with the code (trying to grab the right fields among all the tables) but what you did makes perfect sense.
  11. rseigel

    JOIN Issues

    SELECT * FROM ps_product_supplier JOIN ps_product JOIN ps_product_attribute USING (id_product) WHERE ps_product.active = '1' AND ps_product.ean13 = '' AND ps_product_attribute.ean13 = '' AND ps_product.id_category_default != '73' This doesn't work (no surprise from those with way more experience here than me). The common column between the 3 tables is id_product. I know everything past the WHERE works. Things went sideways when I introduced the 2nd join (ps_product_attribute). Please help.....
  12. I'm such a moron....thanks for that catch.
  13. SELECT * FROM ps_product WHERE ps_product.active = '1' AND ps_product.ean13 = '' AND ps_product.id_category_default != '73' Works perfectly in phpMyAdmin yet when I put it in a QUERY $result = mysqli_query($con,'SELECT * FROM ps_product WHERE ps_product.active = '1' AND ps_product.ean13 = '' AND ps_product.id_category_default != '73'') or die(mysqli_error()); it fails. Thanks, Ron
  14. Thanks very much, That works perfectly. There's a LOT to learn.....
  15. Thanks to everyone that's helped so far. I have another one I can't wrap my head around: I'm using: SELECT * FROM tmp_BF, ps_product WHERE tmp_BF.wholesale_price != (SELECT wholesale_price FROM ps_product) AND tmp_BF.wholesale_price = ps_product.wholesale_price I'm trying to find products that are in both tables where the wholesale price doesn't match. I realize I should be trying to use a JOIN - just not sure how to handle it. Any hints? Thanks, Ron
×
×
  • 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.