
rseigel
Members-
Posts
88 -
Joined
-
Last visited
Everything posted by rseigel
-
LOL....I guess I figured it couldn't possibly be that easy. Turns out it was..... Thanks.
-
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
-
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"); } }
-
AHHHHHHHHHH..... False alarm. Doesn't work after all. I'll create a new thread to try to figure out how to make this work.
-
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.....
-
Yup...my host won't touch this one. Time for plan B....
-
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
-
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.
-
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
-
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.
-
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.....
-
I'm such a moron....thanks for that catch.
-
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
-
Thanks very much, That works perfectly. There's a LOT to learn.....
-
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
-
LOL.....I got it backwards (I need the other one too) SELECT * FROM tmp_BF WHERE supplier_reference NOT IN ( SELECT product_supplier_reference FROM ps_product_supplier
-
I have two tables that I'm trying to compare. I need to find items that are in tmp_BF and not in ps_product_supplier. I'm using: SELECT * FROM ps_product_supplier WHERE ps_product_supplier.product_supplier_reference NOT IN (SELECT supplier_reference FROM tmp_BF); The column names are correct. The table names are correct. It returns zero rows even though I know for a fact that it shouldn't. This must be something simple. Any thoughts? Thanks, Ron
-
I'm a moron.... This works perfectly: $result = mysqli_query($con,'SELECT * FROM tmp_BF WHERE tmp_BF.supplier_reference NOT IN (SELECT supplier_reference FROM ps_product)') or die(mysqli_error()); Thanks for the kick in the right direction.
-
Fixed #1. As far as #2, I'm not sure what you mean. I have the connection at the top of my script. $con = mysqli_connect("localhost","xxxxxx","xxxxx","xxxxx"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } echo "Connected to Database<br /><br />";
-
Thanks very much for the help.... I actually have the SELECT working: $result = mysqli_query('SELECT * FROM tmp_BF WHERE tmp_BF.supplier_reference NOT IN (SELECT supplier_reference FROM ps_product)') or die(mysql_error()); echo "NEW PRODUCTS<br /><br />"; while($row = mysqli_fetch_array($result)) { echo "<a href='https://www.mysupplier.com/item/item.lasso?dsc2={$row['supplier_reference']}'>{$row['supplier_reference']}</a><br />"; } The problem now is that it outputs nothing. If I do the raw SELECT on the database there is a result. Now I"m really confused....
-
Hi all, I'm sure this should be simple but for some reason my brain won't cooperate. I have 2 tables: ps_products and tmp_BF Both of them have a field called supplier_reference. I need to know which records are in ps_products that aren't in tmp_BF and vice-versa. Could someone please kick me in the right direction? Thanks, Ron
-
Hoping someone here is a SOAP genius....I'm not. Using the following script: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $client = new SoapClient("https://blahblahblah.com/soap/20110301/wsdl/ApiRetailerSearch.wsdl", array('trace' => 1)); $objAuth = new stdClass(); $objAuth->username = 'xxxxxxxxx'; $objAuth->password = 'xxxxxxxxxx'; $objRequest = new stdClass(); $objRequest->authentication = $objAuth; $objRequest->retailer_id = 'xxxxxxxx'; $objRequest->products = array(xxxxxxx); $objRequest->items = array(); $objRequest->watchlists = array(); $response = $client->getProductDetail($objRequest); if(false == is_soap_fault($response)){ foreach($response as $product) { foreach ($product->items as $item) { print "price: " . $item->price . "\n\n"; } } print_r($response); }else{ echo "error code: " . $response->faultstring . "<br>"; echo "error message: " . $response->detail . "<br>"; } ?> Get the following error: Fatal error: Uncaught SoapFault exception: [2011] Permission denied. in /home/aonewebs/public_html/doba.php:16 Stack trace: #0 /home/aonewebs/public_html/doba.php(16): SoapClient->__call('getProductDetai...', Array) #1 /home/aonewebs/public_html/doba.php(16): SoapClient->getProductDetail(Object(stdClass)) #2 {main} thrown in /home/aonewebs/public_html/doba.php on line 16 Any ideas? Ron
-
Ohhhhhhh yeaaaaaahhhhhh! It works. Thanks to both of you for the help. It's now exactly what I needed. Off to the next challenge.......
-
Already have that. No errors thrown.....just a blank page.
-
I'm trying to get this code to save a csv file to the root of my hosting accont. $result = mysql_query("SELECT p.reference AS sku, IFNULL( p.price - sp.reduction, p.price ) AS price, sa.quantity, mpo.asin1 AS 'product-id', 'ASIN' AS 'product-id-type', p.condition AS 'condition-type' FROM product p LEFT JOIN specific_price sp USING ( id_product ) JOIN stock_available sa USING ( id_product ) JOIN marketplace_product_option mpo USING ( id_product ) WHERE mpo.asin1 > ''"); if (!$result) die('Couldn\'t fetch records'); $num_fields = mysql_num_fields($result); $headers = array(); for ($i = 0; $i < $num_fields; $i++) { $headers[] = mysql_field_name($result , $i); } $csv_filename = "export-amazon.csv"; $fp = fopen($csv_filename, 'w+'); if ($fp && $result) { fputcsv($fp, $headers); while ($row = mysql_fetch_row($result)) { fputcsv($fp, array_values($row)); } } I've been digging and digging on the internet and nothing seems to work. In the above code, I know for a fact that the SELECT works perfectly. It just doesn't save a file. Any ideas, thoughts, anything?? O_o Thanks,Ron