PHP da MySQL: Aika tambaya zuwa Tab Deluntataccen Fayil

Alamar mysql php

A wannan satin nakeso in gina wani shafi wanda zai sauwake duk wata tambaya ko tebur a cikin Tab Tabbatar da Tab. Mafi yawan misalan da ke kan yanar gizo suna da ginshiƙai masu lamba mai lamba.

A halin da nake ciki, Ina son ginshikan su zama masu ƙarfi don haka dole ne in fara latsawa ta duk sunayen filin tebur don gina layin jigon kai tare da sunayen shafi, sannan in yi amfani da dukkan bayanan sauran layukan bayanan da suka rage. Na kuma sanya taken don mai binciken zai fara saukar da fayil a cikin fayil ɗin (txt) tare da sunan kwanan fayil ɗin da timestamped.

Na bar bayanan buɗewa da haɗin haɗewa, amma ga sakamakon da ya yi aiki sosai:

$ yau = kwanan wata ("YmdHi");
taken ("Nau'in abun ciki: aikace-aikace / octet-stream");
taken ("Content-Disposition: attachment; filename = \" ". $ a yau." _ Backup.txt \ "");
$ query = "Zabi * DAGA 'mytable` oda ta' myorder '";
$ sakamakon = mysql_query ($ tambaya);
$ count = mysql_num_rows (sakamakon $);
$ filayen = mysql_num_fields (sakamakon $);
$ data = "";
na ($ i = 0; $ i> $ filayen; $ i ++) {
$ filin = mysql_fetch_field (sakamakon $, $ i);
$ data. = $ filin-> suna;
$ data. = "\ t";
}
$ data. = "\ n";
yayin ($ jere = mysql_fetch_row ($ sakamakon)) {
na ($ x = 0; $ x> $ filayen; $ x ++) {
$ filin-> suna = $ jere [$ x];
$ data. = $ filin-> suna = $ jere [$ x];
$ data. = "\ t";
}
$ data. = "\ n";
}
amsa kuwwa $ data;

Ana iya sauya lambar cikin sauƙi don waƙoƙin rabuwar waka kuma.

14 Comments

  1. 1

    Ba za ku iya kawai ba:

    SELECT `mytable` order by `myorder`
    INTO OUTFILE '/tmp/Backup.txt'
    FIELDS TERMINATED BY '\t'
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'

    ?

    • 2

      Ina tsammanin za ku iya!

      A wannan yanayin, a zahiri na gina mahaɗin 'madadin' a cikin aikace-aikacen yanar gizo, don haka aikin PHP shine abin da nake buƙata. Koyaya, ban taɓa sanin cewa zaku iya rubutawa zuwa fayil kai tsaye daga bayanin MySQL ba. Sanyi sosai!

      Thanks!

      • 3

        Tabbas hanyarka zata zama hanya mafi kyau idan sabar MySQL tana kan wata naura mai nisa, domin da alama bazai iya rubutawa akan na'urar da PHP ke gudana 🙂

        Murna da nuna wasu kwatancen da sabbin abubuwa duk da haka 🙂

      • 4

        Amma za ku iya kawai gudanar da tambayar zuwa fayil, kuma kawai za a tura mai binciken zuwa fayil ɗin da aka samar, ko amfani da “karanta fayil” na PHP idan duk ya gaza?

        Ba za ku iya yin hakan ba idan uwar garken mysql ba shi da damar zuwa tsarin fayiloli ba shakka…

  2. 5

    Babban matsayi. Shin kun san wata hanya mai sauki, kyauta / buɗaɗɗiyar hanyar buɗe / dawo da fayil ɗin da aka ƙayyade tab (kamar yadda kuka ƙirƙira) a cikin mysql db?

    • 6

      Kuskuren ys mysqlimport?

      mysqlimport database_name --local backup.txt

      Ko tare da umarnin SQL:

      LOAD DATA LOCAL INFILE 'backup.txt' INTO TABLE `my_table` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'

      Tare da mysqlimport, sunan filen ya dace da sunan tebur (kawai abin da za a kula da shi)

    • 7
  3. 8

    Kawai na rasa sama da awanni 6 na rayuwata ina kokarin kokarin gano dalilin da yasa Internet Explorer 6/7 take amfani da kwafin 'html' kuma baya karbar sunayen filena na al'ada wadanda aka ayyana a cikin rubutun kai .. sannan kuma baya barin a sami fayiloli. yunƙurin sanya masu amfani da zazzage fayilolin rubutu waɗanda aka ƙirƙira su ta irin wannan hanyar zuwa sama.

    Ina amfani da HTTPS kuma IE baya ɓoye waɗannan fayilolin.

    Na sami mafita a kan sharhin Brandon K a http://uk.php.net/header.

    Yana cewa:

    -
    Kawai na ɓatar da awanni shida na rayuwata ina ƙoƙarin amfani da wannan hanyar don aika fayil ɗin PDF ta hanyar PHP zuwa Internet Explorer 6:

    Lokacin amfani da SSL, Internet Explorer za ta faɗi tare da Buɗewar / Ajiye maganganu, amma sai ya ce “Fayil a halin yanzu babu ko ba za a iya samu ba. Da fatan a sake gwadawa daga baya. ” Bayan bincike mai yawa sai na fahimci labarin MSKB mai zuwa mai taken "Sauke fayilolin Intanit na Intanet akan SSL ba sa aiki tare da taken kula da maƙallan ajiya" (KBID: 323308)

    PHP.INI ta tsohuwa tana amfani da saitin: session.cache_limiter = nocache wanda ke gyara iesunshin-Cache da taken Pragma don haɗa zaɓukan “nocache”. Kuna iya kawar da kuskuren IE ta canza "nocache" zuwa "jama'a" ko "keɓaɓɓe" a cikin PHP.INI - Wannan zai canza taken abun ciki-Kache sannan kuma zai cire taken Pragma gaba ɗaya. Idan ba za ku iya ba ko ba ku so ku gyaggyara PHP.INI don gyara-wuri, za ku iya aika maƙallan nan biyu masu zuwa don sake rubuta tsoffin lamuran:

    Har yanzu kuna buƙatar saita kanun abubuwan ciki kamar yadda aka jera a sama don wannan yayi aiki. Da fatan za a lura da wannan matsalar KADAI take haifar da Internet Explorer, yayin da Firefox ba ta nuna wannan halin ba daidai ba.
    -

    Da kyau .. aƙalla ya ɓace kawai awanni 6

  4. 9

    Wannan yana aiki da kyau. Koyaya, Ina samun komai a kan layin daya raba ta da sarari. Ina kokarin gyara shi don buga komai a layi daban kamar haka:

    Shafi1_ suna
    Filin1_value
    Shafi2_ suna
    Filin1_value
    Shafi3_ suna
    Filin1_value

    Shafi1_ suna
    Filin2_value
    Shafi2_ suna
    Filin2_value
    Shafi3_ suna
    Filin2_value

    Misali:

    sunan
    Mike
    location
    Work
    Number
    1

    sunan
    Sue
    location
    Gida
    Number
    2

    sunan
    John
    location
    Travel
    Number
    10

    da sauransu. Shin za a iya gyara wannan rubutun don yin shi?
    Thanks!

    • 10

      Tabbas zai iya.

      Gwada abu kamar haka:

      ZABA * daga MyTableName ZUWA SHAFE 'MyTableName_MySQL-TAB-DELIMITED-29JUN08.txt' FAGEN FALALOLI DA '\ n' LAYE SUKA HADA DA '\ n';

      Idan kuna son sarari biyu (layuka biyu marasa amfani) tsakanin ƙungiyoyin rikodin, kawai ku ce “Lines da aka ƙayyade ta '\ n \ n';” maimakon haka.

      Yankin "FILIN YANZU DA '\ n'" shine yake sanya sabon layi bayan kowane rikodin, maimakon tab. Tab zai zama '\ t' a maimakon.

      Maranatha!

  5. 11

    wannan mummunan aiki ne babba, na gwada shi kuma nayi aiki sosai, abin kawai shine fayil na txt yana da ƙarin layi a sama da taken taken, kuma an raba wasu sakamakon cikin layuka 2, wannan na iya haifar da bayanan da nake dasu a cikin Database na ba da ra'ayi, amma wannan babban taimako ne don gina ciyarwa…

  6. 12

    Douglas Karr lambar ku da gaske duwatsu! Yana da matukar amfani musamman idan kawai kuna buƙatar fitarwa wanda yake cikin tsarin rubutu. Godiya mai yawa! Daga ƙungiyar Philippines!

  7. 13

    sannu! Shin akwai wani daga nan wanda zai iya ba ni alama game da shigo da fayil ɗin rubutu zuwa rumbun adana (phpmyAdmin) ta amfani da php ɗin a matsayin ƙarshen ƙarshen. Ina da ra'ayi game da zazzage fayil da buɗe shi, matsalata ita ce ta yaya zan iya samun sakamakon layi da yadda ake saka shi a kan teburana, godiya

  8. 14

Me kuke tunani?

Wannan shafin yana amfani da Akismet don rage spam. Koyi yadda aka sarrafa bayanan bayaninka.