Is het mogelijk om data uit een url te halen die in csv formaat staat en dan in een fromulier in te vullen dmv variables? Ik wil bijvoorbeeld deze data in een webformulier kunnen plaatsen om te bewerken en dan naar mijn database te versturen. Formulier ens heb ik werkend maar vroeg mij af of deze gegevens vanuit een webadres naar mijn reeds bestaande formulier kan zenden

http://data.icecat.biz/xml_s3/xml_server3.cgi?ean_upc=8711500354532,8711500354501;lang=EN;output=productcsv

Dit is de data die ik krijg als ik de bovenstaande link in mijn browser aanvraag:

"Requested_prod_id","Requested_GTIN(EAN/UPC)","Requested_Icecat_id","ErrorMessage","Supplier","Prod_id","Icecat_id","GTIN(EAN/UPC)","Category","CatId","ProductFamily","ProductSeries","Model","Updated","Quality","On_Market","Product_Views","HighPic","HighPic Resolution","LowPic","Pic500x500","ThumbPic","Folder_PDF","Folder_Manual_PDF","ProductTitle","ShortDesc","ShortSummaryDescription","LongSummaryDescription","LongDesc","ProductGallery","ProductGallery Resolution","360","EU Energy Label","EU Product Fiche","PDF","Video/mp4","Other Multimedia","ReasonsToBuy","Spec 1","Spec 2","Spec 3","Spec 4","Spec 5","Spec 6","Spec 7","Spec 8","Spec 9","Spec 10","Spec 11","Spec 12","Spec 13","Spec 14","Spec 15","Spec 16","Spec 17","Spec 18","Spec 19","Spec 20","Spec 21","Spec 22"
"","8711500354532","","","Philips","926000000885","3993245","8711500354532|8711500354549","incandescent bulbs","","","","Standard 40W","20140808190953","ICECAT","1","25415","http://images.icecat.biz/img/norm/high/3993245-7010.jpg","358x358","http://images.icecat.biz/img/norm/low/3993245-7010.jpg","","http://images.icecat.biz/thumbs/3993245.jpg","","","Philips Standard 40W","","Philips Standard 40W","Philips Standard 40W","","http://images.icecat.biz/img/gallery/3993245_1262.jpg|http://images.icecat.biz/img/gallery/3993245_2753.jpg|http://images.icecat.biz/img/gallery/3993245_7559.jpg","2000x1952|1788x871|2000x1416","","","","","","","","Performance","Bulb power: 40 W","Bulb shape: A55","Fitting/cap type: E27","Luminous flux: 415 lm","Bulb lifetime: 1000 h","Light colour: Clear","Type finish: Clear","Colour temperature: 2700 K","Colour of product: Transparent","Dimmable: Yes","Color Rendering Index (CRI): 100","Power","Input voltage: 230","Energy efficiency class: E","Weight & dimensions","Weight: 25 g","Width: 6 cm","Depth: 6 cm","Height: 10 cm","Packaging data","Quantity: 1"
"","8711500354501","","","Philips","354501 84","4135316","8711500354501","incandescent bulbs","","","","Standard 25W E27 230V A55 CL 1CT","20130313153027","ICECAT","","10167","http://images.icecat.biz/img/norm/high/4135316-3882.jpg","326x210","http://images.icecat.biz/img/norm/low/4135316-3882.jpg","","http://images.icecat.biz/thumbs/4135316.jpg","","","Philips Standard 25W E27 230V A55 CL 1CT","","Philips Standard 25W E27 230V A55 CL 1CT","Philips Standard 25W E27 230V A55 CL 1CT","","","","","","","","","","","Performance","Bulb power: 25 W","Fitting/cap type: E27","Luminous flux: 220 lm","Bulb lifetime: 1000 h","Colour temperature: 2700 K","Power","Energy efficiency class: E","Power requirements: 230V","","","","","","","","","","","","",""

De url zit achter een login. Mogelijk kan het met curl uitgelezen worden.

Daarna kun je fgetcsv gebruiken
Ik heb de gebruikersnaam en wachtwoord, hoe gebruik ik curl met deze url?
<?php
$username = "Username";
$password = "Geheim";
$url = "http://www.website.nl/script.php";;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
$result = curl_exec($ch);
curl_close($ch);

// de output gaan we nu tonen:
echo $result;
?>
Wat knap van je Aar, het werkt :D Nu krijg ik alle data zoals in mijn eerste bericht in mijn pagina boven het formulier. Hoe krijg ik nou een waarde bv Requested_GTIN(EAN/UPC) wat 8711500354532 is gekoppeld aan een $var Ik moet een aantal waardes uit deze list halen om in mijn formulier te zetten. Ik denk als ik een er uit kan halen dan komt de rest wel goed ;-)
Ik heb de hele avond van alles geprobeerd op de website die je stuurde maar de enige resultaat die ik krijg is het woordje array zonder verdere data

<?php
$data = str_getcsv($result,"\n");

echo $data;
?>
Met alleen array()? dan moet je print_r() gebruiken..

<?php
$data = str_getcsv($result,"\n");

print_r($data);
?> 
Elke komma is gescheiden.

Dus $data is de array.
$data[0]
$data[1]
$data[2]

Dat zijn je variabelen.

Reageren