Pogledajte određenu poruku
Staro 25. 08. 2015.   #1
stanke
član
Certified
 
Datum učlanjenja: 06.09.2012
Poruke: 64
Hvala: 0
342 "Hvala" u 10 poruka
stanke is on a distinguished roadstanke is on a distinguished roadstanke is on a distinguished roadstanke is on a distinguished road
Default csv fajl provera duplih vrednost

Pozdrav imam problem sa csv fajlom, hocu pre unosa u bazu da proverim dal ima duple zapise, ali proveravam samo prvu kolonu u kodu je do $data[0], ukoliko ima duplih vrednosti izbaci gresku i prekini unos tj. da se unis u tabelu ne izvrsi.
Evo ga kod:

HTML kôd:
$konekcija_amso = pg_connect("dbname=mojabaza user=userja host=localhost" );
if(isset($_POST['enter'])) 
{
       $fajl = $_FILES['file']['tmp_name'];
    if((($handle = fopen($fajl, 'r')) !== false))
        {
            while(($data = fgetcsv($handle,1000, ',')) !== false)
            {

/*
pre unosa da se izvrsi provera za $data[0] dal ima duple - iste vrednosti ukoliko ima izbaciti gresku i obustaviti unos


            */
            
            $sql = "INSERT INTO csvtrenutna (brpolise, iznos) VALUES('".$data[0]."', '".$data[1]."')";
            pg_query($konekcija, $sql);
            
         
        }
        
    }
    fclose($handle);
}

<form action="" method="post" enctype="multipart/form-data" id="formarasknjizavanje">
        <input type="file" name="file" id = "file" >
   
        <input type="button" name="enter" value="Rasknjizi">
    </form>
Jel ima neko neku ideju kako bi to izveo hvala
stanke je offline   Odgovorite uz citat
82 članova zahvaljuje stanke za poruku:
achelmeyerneilk, allen4jim, ardgraafwilfo, areraodel, aschoonovemaked, bapplebattery, bilpboyc, budblak, celebritybrautk, cfacecheap, cfakecoach, cstorecanada, ctarrickdied, cteciuccihenr, dgendant, dnhardwmrei, dorflesnersalva, dswhiddendema, dyejidemcki, eabuechersophi, econeclar, eeblinetyron, emcqueenanto, encasteranto, ershauerbric, esbardneymarku, esbissonetulyss, fhrentfrokhad, iaidimarc, ichristianheels, idvddisney, klockelmo, ksaajokuthere, ktrackeisid, kwinskiiren, larholburt, lemosellerobbi, lerolees, llpiccillorache, lmesserlymisty, metwmper, minsmacw, nesimankricki, neveningparty, ngreenbackmarti, nincenorah, nkallenbemaur, nnaellanknatha, nordinoscot, nramanyjule, nrtmanwenwe, nteilingayan, oegwoodsydn, oitchmorerowe, oldutkomigue, osjoem, otkersonlesl, pcheapface, prdpala, qlspraquemars, rahrexv, rdemarckris, rdheminovemayna, reckleromarh, rlamryan, rnslerwend, ronicodemumilag, ruhnerrenek, sairdiscount, skocsismoshe, sosephsenbust, srerasruss, stensmaik, tezabielskyevet, tineheindevalen, tjohnstonhayw, tmiretedad, ueesaunanni, uungblutsonyo, vienvert, waskiewichowa, ytelajoyetonet