答:
This is a JSON, not a csv.

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

You can paste the content here to read it.
(Notice that you lost a } at the end of the content posted in question.)

Send the file to ningshen_zhang@163.com. Let me help you to convert.

Or you may do it yourself. Here is the code in C#:

using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;

namespace SharpTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string filePath = "XXX/content.json";
            string savePath = "XXX/output.csv";
            string json = File.ReadAllText(filePath);
            var re = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json);
            using(StreamWriter writer = new StreamWriter(savePath))
            {
                foreach(var pair1 in re)
                {
                    foreach(var pair2 in pair1.Value)
                    {
                        foreach(var pair3 in pair2.Value)
                        {
                            if(pair3.Key.StartsWith("fk_")) continue;
                            writer.WriteLine(pair1.Key + "," + pair3.Key + ",\"" + pair3.Value + '"');
                        }
                    }
                }
            }
        }
    }
}
```

Title: Data cleaning of csv file with many separated criteria

Body:
I am struggling in cleaning up and organize the file I attached.
I would need to "clean" the csv file organized in lists and sublists separated by different criteria such as : , comma and {.
I need three columns that show:
-in the first column the number that identify the profession such as "1.1.1.1.0";
-the second column I need the number that identify the characteristic of the profession: there are "attitudini", that has characteristics from "D10a" to "D9b" ; after that there are "competenze" from "C10a" to "C9b"
-the last column should report the value of each characteristic defined in the previous column, for example for the occupation 1.1.1.1.0, attitude D10a is equal to 60.

I give you a subsample example here with just two occupation but I would clean the whole sample with 786 occupations. If necessary I can send you the whole one.
many thanks to whoever can give me some hints.

Best

Roberta

{ "1.1.1.1.0":{ "attitudini":{ "D10a":"60.00000", "D10b":"51.00000", "D11a":"50.00000", "D11b":"39.00000", "D12a":"25.00000", "D12b":"28.00000", "D13a":"45.00000", "D13b":"48.00000", "D14a":"70.00000", "D14b":"71.00000", "D15a":"85.00000", "D15b":"74.00000", "D16a":"50.00000", "D16b":"48.00000", "D17a":"40.00000", "D17b":"40.00000", "D18a":"35.00000", "D18b":"31.00000", "D19a":"40.00000", "D19b":"48.00000", "D1a":"80.00000", "D1b":"82.00000", "D20a":"50.00000", "D20b":"57.00000", "D21a":"90.00000", "D21b":"68.00000", "D22a":"0.00000", "D22b":"0.00000", "D23a":"0.00000", "D23b":"0.00000", "D24a":"0.00000", "D24b":"0.00000", "D25a":"0.00000", "D25b":"0.00000", "D26a":"0.00000", "D26b":"0.00000", "D27a":"0.00000", "D27b":"0.00000", "D28a":"0.00000", "D28b":"0.00000", "D29a":"0.00000", "D29b":"0.00000", "D2a":"75.00000", "D2b":"71.00000", "D30a":"0.00000", "D30b":"0.00000", "D31a":"0.00000", "D31b":"0.00000", "D32a":"0.00000", "D32b":"0.00000", "D33a":"0.00000", "D33b":"0.00000", "D34a":"0.00000", "D34b":"0.00000", "D35a":"0.00000", "D35b":"0.00000", "D36a":"10.00000", "D36b":"8.00000", "D37a":"0.00000", "D37b":"0.00000", "D38a":"0.00000", "D38b":"0.00000", "D39a":"0.00000", "D39b":"0.00000", "D3a":"85.00000", "D3b":"83.00000", "D40a":"0.00000", "D40b":"0.00000", "D41a":"15.00000", "D41b":"14.00000", "D42a":"0.00000", "D42b":"0.00000", "D43a":"0.00000", "D43b":"0.00000", "D44a":"0.00000", "D44b":"0.00000", "D45a":"0.00000", "D45b":"0.00000", "D46a":"0.00000", "D46b":"0.00000", "D47a":"0.00000", "D47b":"0.00000", "D48a":"15.00000", "D48b":"17.00000", "D49a":"10.00000", "D49b":"8.00000", "D4a":"75.00000", "D4b":"77.00000", "D50a":"5.00000", "D50b":"6.00000", "D51a":"45.00000", "D51b":"54.00000", "D52a":"85.00000", "D52b":"94.00000", "D5a":"55.00000", "D5b":"51.00000", "D6a":"70.00000", "D6b":"65.00000", "D7a":"80.00000", "D7b":"85.00000", "D8a":"70.00000", "D8b":"65.00000", "D9a":"60.00000", "D9b":"54.00000", "fk_livello5":"1.1.1.1.0" }, "competenze":{ "C10a":"70.00000", "C10b":"74.00000", "C11a":"90.00000", "C11b":"77.00000", "C12a":"70.00000", "C12b":"74.00000", "C13a":"70.00000", "C13b":"80.00000", "C14a":"75.00000", "C14b":"77.00000", "C15a":"50.00000", "C15b":"45.00000", "C16a":"60.00000", "C16b":"54.00000", "C17a":"80.00000", "C17b":"80.00000", "C18a":"35.00000", "C18b":"37.00000", "C19a":"10.00000", "C19b":"8.00000", "C1a":"90.00000", "C1b":"82.00000", "C20a":"55.00000", "C20b":"54.00000", "C21a":"5.00000", "C21b":"6.00000", "C22a":"0.00000", "C22b":"0.00000", "C23a":"20.00000", "C23b":"20.00000", "C24a":"0.00000", "C24b":"0.00000", "C25a":"0.00000", "C25b":"0.00000", "C26a":"0.00000", "C26b":"0.00000", "C27a":"45.00000", "C27b":"40.00000", "C28a":"0.00000", "C28b":"0.00000", "C29a":"50.00000", "C29b":"68.00000", "C2a":"75.00000", "C2b":"83.00000", "C30a":"35.00000", "C30b":"43.00000", "C31a":"85.00000", "C31b":"83.00000", "C32a":"70.00000", "C32b":"57.00000", "C33a":"45.00000", "C33b":"48.00000", "C34a":"25.00000", "C34b":"28.00000", "C35a":"75.00000", "C35b":"63.00000", "C3a":"80.00000", "C3b":"77.00000", "C4a":"75.00000", "C4b":"85.00000", "C5a":"25.00000", "C5b":"25.00000", "C6a":"35.00000", "C6b":"31.00000", "C7a":"85.00000", "C7b":"85.00000", "C8a":"75.00000", "C8b":"74.00000", "C9a":"45.00000", "C9b":"37.00000", "fk_livello5":"1.1.1.1.0" }, "compiti":{ "p1":"votare normative o trasformare in leggi le proposte di legge", "p10":"leggere i giornali e tenersi aggiornati", "p11":"nominare gli amministratori di aziende partecipate dello stato italiano", "p12":"partecipare a commissioni parlamentari", "p13":"partecipare a convegni, conferenze o congressi", "p14":"trasformare in leggi gli atti del governo", "p2":"svolgere attività istruttoria (interrogazioni, interpellanze, ecc.)", "p3":"tenere i rapporti con il partito di appartenenza", "p4":"partecipare a dibattiti e a trasmissioni radiotelevisive", "p5":"recepire istanze provenienti dal sociale", "p6":"tenere i rapporti con l'elettorato (favorire la partecipazione dei cittadini, divulgare i risultati ottenuti, ecc.)", "p7":"discutere o emendare provvedimenti", "p8":"progettare e avanzare proposte di legge", "p9":"condurre indagini conoscitive su alcuni settori particolari del paese" }, "condizioni_lavoro":{ "H1":"95.00000", "H10":"20.00000", "H11":"55.00000", "H12":"85.00000", "H13":"75.00000", "H14":"25.00000", "H15":"95.00000", "H16":"25.00000", "H17":"50.00000", "H18":"10.00000", "H19":"0.00000", "H2":"80.00000", "H20":"20.00000", "H21":"55.00000", "H22":"20.00000", "H23":"0.00000", "H24":"0.00000", "H25":"0.00000", "H26":"0.00000", "H27":"0.00000", "H28":"0.00000", "H29":"0.00000", "H3":"100.00000", "H30":"0.00000", "H31":"0.00000", "H32":"0.00000", "H33":"0.00000", "H34":"80.00000", "H35":"0.00000", "H36":"25.00000", "H37":"0.00000", "H38":"5.00000", "H39":"35.00000", "H4":"100.00000", "H40":"15.00000", "H41":"5.00000", "H42":"20.00000", "H43":"0.00000", "H44":"0.00000", "H45":"70.00000", "H46":"70.00000", "H47":"90.00000", "H48":"80.00000", "H49":"20.00000", "H5":"95.00000", "H50":"75.00000", "H51":"60.00000", "H52":"70.00000", "H53":"90.00000", "H54":"85.00000", "H55":"0.00000", "H56":"10.00000", "H57":"64.00000", "H6":"90.00000", "H7":"85.00000", "H8":"80.00000", "H9":"75.00000", "fk_livello5":"1.1.1.1.0" }, "conoscenze":{ "B10a":"15.00000", "B10b":"11.00000", "B11a":"0.00000", "B11b":"0.00000", "B12a":"15.00000", "B12b":"11.00000", "B13a":"15.00000", "B13b":"17.00000", "B14a":"30.00000", "B14b":"25.00000", "B15a":"5.00000", "B15b":"3.00000", "B16a":"20.00000", "B16b":"20.00000", "B17a":"20.00000", "B17b":"20.00000", "B18a":"50.00000", "B18b":"48.00000", "B19a":"55.00000", "B19b":"57.00000", "B1a":"45.00000", "B1b":"43.00000", "B20a":"45.00000", "B20b":"54.00000", "B21a":"15.00000", "B21b":"11.00000", "B22a":"0.00000", "B22b":"0.00000", "B23a":"40.00000", "B23b":"45.00000", "B24a":"75.00000", "B24b":"74.00000", "B25a":"55.00000", "B25b":"60.00000", "B26a":"10.00000", "B26b":"11.00000", "B27a":"70.00000", "B27b":"62.00000", "B28a":"60.00000", "B28b":"65.00000", "B29a":"65.00000", "B29b":"57.00000", "B2a":"50.00000", "B2b":"57.00000", "B30a":"95.00000", "B30b":"86.00000", "B31a":"30.00000", "B31b":"28.00000", "B32a":"80.00000", "B32b":"74.00000", "B33a":"40.00000", "B33b":"34.00000", "B3a":"70.00000", "B3b":"62.00000", "B4a":"10.00000", "B4b":"11.00000", "B5a":"85.00000", "B5b":"77.00000", "B6a":"55.00000", "B6b":"48.00000", "B7a":"30.00000", "B7b":"34.00000", "B8a":"10.00000", "B8b":"11.00000", "B9a":"25.00000", "B9b":"25.00000", "fk_livello5":"1.1.1.1.0" }, "gwa":{ "G10a":"90.00000", "G10b":"91.00000", "G11a":"65.00000", "G11b":"68.00000", "G12a":"90.00000", "G12b":"88.00000", "G13a":"70.00000", "G13b":"71.00000", "G14a":"80.00000", "G14b":"71.00000", "G15a":"95.00000", "G15b":"82.00000", "G16a":"5.00000", "G16b":"3.00000", "G17a":"0.00000", "G17b":"0.00000", "G18a":"0.00000", "G18b":"0.00000", "G19a":"55.00000", "G19b":"42.00000", "G1a":"85.00000", "G1b":"88.00000", "G20a":"0.00000", "G20b":"0.00000", "G21a":"0.00000", "G21b":"0.00000", "G22a":"0.00000", "G22b":"0.00000", "G23a":"0.00000", "G23b":"0.00000", "G24a":"60.00000", "G24b":"57.00000", "G25a":"50.00000", "G25b":"51.00000", "G26a":"85.00000", "G26b":"82.00000", "G27a":"75.00000", "G27b":"79.00000", "G28a":"85.00000", "G28b":"85.00000", "G29a":"45.00000", "G29b":"37.00000", "G2a":"60.00000", "G2b":"51.00000", "G30a":"50.00000", "G30b":"45.00000", "G31a":"60.00000", "G31b":"71.00000", "G32a":"75.00000", "G32b":"79.00000", "G33a":"65.00000", "G33b":"60.00000", "G34a":"70.00000", "G34b":"60.00000", "G35a":"55.00000", "G35b":"54.00000", "G36a":"70.00000", "G36b":"54.00000", "G37a":"75.00000", "G37b":"68.00000", "G38a":"45.00000", "G38b":"43.00000", "G39a":"25.00000", "G39b":"28.00000", "G3a":"40.00000", "G3b":"40.00000", "G40a":"30.00000", "G40b":"28.00000", "G41a":"30.00000", "G41b":"28.00000", "G4a":"15.00000", "G4b":"14.00000", "G5a":"45.00000", "G5b":"40.00000", "G6a":"50.00000", "G6b":"48.00000", "G7a":"50.00000", "G7b":"51.00000", "G8a":"55.00000", "G8b":"65.00000", "G9a":"45.00000", "G9b":"48.00000", "fk_livello5":"1.1.1.1.0" }, "stili_lavoro":{ "F1":"75.00000", "F10":"70.00000", "F11":"95.00000", "F12":"80.00000", "F13":"100.00000", "F14":"75.00000", "F15":"80.00000", "F16":"90.00000", "F2":"85.00000", "F3":"90.00000", "F4":"80.00000", "F5":"70.00000", "F6":"80.00000", "F7":"60.00000", "F8":"80.00000", "F9":"85.00000", "fk_livello5":"1.1.1.1.0" }, "valori_professione":{ "E1":"60.00000", "E10":"40.00000", "E11":"70.00000", "E12":"40.00000", "E13":"0.00000", "E14":"90.00000", "E15":"60.00000", "E16":"50.00000", "E17":"40.00000", "E18":"20.00000", "E19":"70.00000", "E2":"60.00000", "E20":"20.00000", "E21":"50.00000", "E3":"80.00000", "E4":"30.00000", "E5":"50.00000", "E6":"90.00000", "E7":"10.00000", "E8":"30.00000", "E9":"50.00000", "fk_livello5":"1.1.1.1.0" } }, "1.1.1.2.0":{ "attitudini":{ "D10a":"58.00000", "D10b":"50.00000", "D11a":"49.00000", "D11b":"49.00000", "D12a":"22.00000", "D12b":"25.00000", "D13a":"29.00000", "D13b":"34.00000", "D14a":"63.00000", "D14b":"58.00000", "D15a":"72.00000", "D15b":"68.00000", "D16a":"50.00000", "D16b":"50.00000", "D17a":"33.00000", "D17b":"37.00000", "D18a":"14.00000", "D18b":"14.00000", "D19a":"18.00000", "D19b":"20.00000", "D1a":"87.00000", "D1b":"78.00000", "D20a":"62.00000", "D20b":"57.00000", "D21a":"79.00000", "D21b":"71.00000", "D22a":"1.00000", "D22b":"1.00000", "D23a":"0.00000", "D23b":"0.00000", "D24a":"1.00000", "D24b":"1.00000", "D25a":"0.00000", "D25b":"0.00000", "D26a":"0.00000", "D26b":"0.00000", "D27a":"0.00000", "D27b":"0.00000", "D28a":"0.00000", "D28b":"0.00000", "D29a":"0.00000", "D29b":"0.00000", "D2a":"92.00000", "D2b":"79.00000", "D30a":"0.00000", "D30b":"0.00000", "D31a":"0.00000", "D31b":"0.00000", "D32a":"0.00000", "D32b":"0.00000", "D33a":"0.00000", "D33b":"0.00000", "D34a":"0.00000", "D34b":"0.00000", "D35a":"0.00000", "D35b":"0.00000", "D36a":"3.00000", "D36b":"1.00000", "D37a":"0.00000", "D37b":"0.00000", "D38a":"0.00000", "D38b":"0.00000", "D39a":"0.00000", "D39b":"0.00000", "D3a":"89.00000", "D3b":"82.00000", "D40a":"0.00000", "D40b":"0.00000", "D41a":"11.00000", "D41b":"13.00000", "D42a":"7.00000", "D42b":"11.00000", "D43a":"4.00000", "D43b":"4.00000", "D44a":"4.00000", "D44b":"4.00000", "D45a":"4.00000", "D45b":"4.00000", "D46a":"1.00000", "D46b":"1.00000", "D47a":"1.00000", "D47b":"1.00000", "D48a":"7.00000", "D48b":"4.00000", "D49a":"8.00000", "D49b":"7.00000", "D4a":"83.00000", "D4b":"78.00000", "D50a":"12.00000", "D50b":"10.00000", "D51a":"22.00000", "D51b":"23.00000", "D52a":"71.00000", "D52b":"65.00000", "D5a":"64.00000", "D5b":"67.00000", "D6a":"57.00000", "D6b":"57.00000", "D7a":"75.00000", "D7b":"73.00000", "D8a":"80.00000", "D8b":"74.00000", "D9a":"79.00000", "D9b":"73.00000", "fk_livello5":"1.1.1.2.0" }, "competenze":{ "C10a":"70.00000", "C10b":"68.00000", "C11a":"67.00000", "C11b":"66.00000", "C12a":"72.00000", "C12b":"75.00000", "C13a":"75.00000", "C13b":"76.00000", "C14a":"83.00000", "C14b":"79.00000", "C15a":"53.00000", "C15b":"50.00000", "C16a":"70.00000", "C16b":"66.00000", "C17a":"80.00000", "C17b":"76.00000", "C18a":"66.00000", "C18b":"64.00000", "C19a":"5.00000", "C19b":"7.00000", "C1a":"97.00000", "C1b":"84.00000", "C20a":"32.00000", "C20b":"35.00000", "C21a":"3.00000", "C21b":"3.00000", "C22a":"0.00000", "C22b":"0.00000", "C23a":"29.00000", "C23b":"24.00000", "C24a":"0.00000", "C24b":"0.00000", "C25a":"0.00000", "C25b":"0.00000", "C26a":"0.00000", "C26b":"0.00000", "C27a":"58.00000", "C27b":"57.00000", "C28a":"0.00000", "C28b":"0.00000", "C29a":"53.00000", "C29b":"57.00000", "C2a":"92.00000", "C2b":"84.00000", "C30a":"55.00000", "C30b":"55.00000", "C31a":"79.00000", "C31b":"78.00000", "C32a":"79.00000", "C32b":"72.00000", "C33a":"75.00000", "C33b":"66.00000", "C34a":"36.00000", "C34b":"34.00000", "C35a":"72.00000", "C35b":"70.00000", "C3a":"84.00000", "C3b":"79.00000", "C4a":"92.00000", "C4b":"85.00000", "C5a":"26.00000", "C5b":"30.00000", "C6a":"13.00000", "C6b":"15.00000", "C7a":"83.00000", "C7b":"79.00000", "C8a":"79.00000", "C8b":"72.00000", "C9a":"43.00000", "C9b":"41.00000", "fk_livello5":"1.1.1.2.0" }, "compiti":{ "p1":"progettare e avanzare proposte di legge", "p10":"curare i rapporti con le istituzioni", "p11":"curare i rapporti con rappresentanti politici, sindacali, economici e sociali", "p12":"emettere ordinanze o delibere", "p13":"organizzare o partecipare a eventi (convegni, comizi, congressi, manifestazioni, ecc.)", "p14":"organizzare/partecipare a riunioni", "p15":"recepire istanze provenienti dal territorio", "p16":"curare i rapporti con soggetti o enti esterni", "p17":"discutere o emendare provvedimenti", "p18":"formulare pareri o proposte", "p19":"gestire le risorse finanziarie", "p2":"prendere parte alle sedute del consiglio o della giunta", "p20":"tenere i rapporti con il partito di appartenenza", "p21":"tenere i rapporti con l'elettorato (favorire la partecipazione dei cittadini, divulgare i risultati ottenuti, ecc.)", "p22":"aggiornarsi sulla normativa vigente", "p23":"curare i rapporti con i mezzi di informazione", "p24":"gestire e/o coordinare le risorse umane", "p25":"istruire procedimenti amministrativi", "p26":"rappresentare il consiglio o la giunta regionale", "p27":"svolgere attività istruttoria (interrogazioni, interpellanze, ecc.)", "p28":"cercare e reperire finanziamenti", "p29":"collaborare con le autorità politiche", "p3":"partecipare alle sedute delle commissioni", "p30":"curare i rapporti con i rappresentanti di altri partiti", "p31":"esercitare vigilanza amministrativa su enti controllati dalla regione", "p32":"verificare i risultati", "p4":"organizzare il lavoro o le attività", "p5":"votare normative o trasformare in leggi le proposte di legge", "p6":"applicare norme o regolamenti", "p7":"far parte di organi istituzionali", "p8":"impostare, sviluppare o controllare la realizzazione dei progetti", "p9":"svolgere attività di controllo sull'azione degli organismi di governo" }, "condizioni_lavoro":{ "H1":"96.05263", "H10":"30.26316", "H11":"64.47368", "H12":"68.42105", "H13":"48.68421", "H14":"2.63158", "H15":"94.73684", "H16":"11.84211", "H17":"21.05263", "H18":"1.31579", "H19":"0.00000", "H2":"65.78947", "H20":"32.89474", "H21":"31.57895", "H22":"18.42105", "H23":"7.89474", "H24":"0.00000", "H25":"0.00000", "H26":"0.00000", "H27":"0.00000", "H28":"0.00000", "H29":"0.00000", "H3":"100.00000", "H30":"0.00000", "H31":"0.00000", "H32":"0.00000", "H33":"0.00000", "H34":"71.05263", "H35":"0.00000", "H36":"23.68421", "H37":"0.00000", "H38":"0.00000", "H39":"30.26316", "H4":"100.00000", "H40":"2.63158", "H41":"0.00000", "H42":"5.26316", "H43":"0.00000", "H44":"0.00000", "H45":"56.57895", "H46":"80.26316", "H47":"67.10526", "H48":"75.00000", "H49":"6.57895", "H5":"93.42105", "H50":"64.47368", "H51":"21.05263", "H52":"68.42105", "H53":"75.00000", "H54":"65.78947", "H55":"3.94737", "H56":"5.26316", "H57":"55.15789", "H6":"92.10526", "H7":"81.57895", "H8":"69.73684", "H9":"75.00000", "fk_livello5":"1.1.1.2.0" }, "conoscenze":{ "B10a":"13.00000", "B10b":"15.00000", "B11a":"3.00000", "B11b":"8.00000", "B12a":"8.00000", "B12b":"6.00000", "B13a":"3.00000", "B13b":"4.00000", "B14a":"29.00000", "B14b":"35.00000", "B15a":"7.00000", "B15b":"11.00000", "B16a":"5.00000", "B16b":"5.00000", "B17a":"5.00000", "B17b":"6.00000", "B18a":"51.00000", "B18b":"53.00000", "B19a":"43.00000", "B19b":"42.00000", "B1a":"57.00000", "B1b":"50.00000", "B20a":"22.00000", "B20b":"24.00000", "B21a":"1.00000", "B21b":"2.00000", "B22a":"11.00000", "B22b":"8.00000", "B23a":"39.00000", "B23b":"42.00000", "B24a":"87.00000", "B24b":"77.00000", "B25a":"54.00000", "B25b":"53.00000", "B26a":"7.00000", "B26b":"8.00000", "B27a":"26.00000", "B27b":"30.00000", "B28a":"26.00000", "B28b":"28.00000", "B29a":"45.00000", "B29b":"44.00000", "B2a":"37.00000", "B2b":"35.00000", "B30a":"87.00000", "B30b":"82.00000", "B31a":"30.00000", "B31b":"23.00000", "B32a":"61.00000", "B32b":"55.00000", "B33a":"25.00000", "B33b":"28.00000", "B3a":"43.00000", "B3b":"43.00000", "B4a":"24.00000", "B4b":"25.00000", "B5a":"61.00000", "B5b":"61.00000", "B6a":"55.00000", "B6b":"52.00000", "B7a":"22.00000", "B7b":"24.00000", "B8a":"11.00000", "B8b":"11.00000", "B9a":"28.00000", "B9b":"28.00000", "fk_livello5":"1.1.1.2.0" }, "gwa":{ "G10a":"82.00000", "G10b":"75.00000", "G11a":"62.00000", "G11b":"60.00000", "G12a":"74.00000", "G12b":"69.00000", "G13a":"79.00000", "G13b":"70.00000", "G14a":"64.00000", "G14b":"65.00000", "G15a":"75.00000", "G15b":"69.00000", "G16a":"0.00000", "G16b":"0.00000", "G17a":"0.00000", "G17b":"0.00000", "G18a":"0.00000", "G18b":"0.00000", "G19a":"39.00000", "G19b":"33.00000", "G1a":"74.00000", "G1b":"70.00000", "G20a":"5.00000", "G20b":"1.00000", "G21a":"5.00000", "G21b":"5.00000", "G22a":"0.00000", "G22b":"0.00000", "G23a":"0.00000", "G23b":"0.00000", "G24a":"32.00000", "G24b":"36.00000", "G25a":"66.00000", "G25b":"58.00000", "G26a":"80.00000", "G26b":"76.00000", "G27a":"88.00000", "G27b":"85.00000", "G28a":"91.00000", "G28b":"80.00000", "G29a":"36.00000", "G29b":"33.00000", "G2a":"50.00000", "G2b":"47.00000", "G30a":"14.00000", "G30b":"18.00000", "G31a":"70.00000", "G31b":"71.00000", "G32a":"47.00000", "G32b":"46.00000", "G33a":"71.00000", "G33b":"70.00000", "G34a":"64.00000", "G34b":"59.00000", "G35a":"33.00000", "G35b":"36.00000", "G36a":"68.00000", "G36b":"70.00000", "G37a":"50.00000", "G37b":"49.00000", "G38a":"55.00000", "G38b":"55.00000", "G39a":"26.00000", "G39b":"25.00000", "G3a":"25.00000", "G3b":"24.00000", "G40a":"33.00000", "G40b":"35.00000", "G41a":"67.00000", "G41b":"69.00000", "G4a":"11.00000", "G4b":"10.00000", "G5a":"26.00000", "G5b":"29.00000", "G6a":"46.00000", "G6b":"46.00000", "G7a":"55.00000", "G7b":"52.00000", "G8a":"38.00000", "G8b":"38.00000", "G9a":"61.00000", "G9b":"54.00000", "fk_livello5":"1.1.1.2.0" }, "stili_lavoro":{ "F1":"80.00000", "F10":"82.00000", "F11":"91.00000", "F12":"74.00000", "F13":"93.00000", "F14":"76.00000", "F15":"72.00000", "F16":"82.00000", "F2":"84.00000", "F3":"80.00000", "F4":"82.00000", "F5":"86.00000", "F6":"84.00000", "F7":"86.00000", "F8":"83.00000", "F9":"86.00000", "fk_livello5":"1.1.1.2.0" }, "valori_professione":{ "E1":"61.00000", "E10":"21.00000", "E11":"61.00000", "E12":"50.00000", "E13":"45.00000", "E14":"66.00000", "E15":"61.00000", "E16":"32.00000", "E17":"26.00000", "E18":"8.00000", "E19":"50.00000", "E2":"47.00000", "E20":"37.00000", "E21":"55.00000", "E3":"74.00000", "E4":"13.00000", "E5":"63.00000", "E6":"58.00000", "E7":"18.00000", "E8":"37.00000", "E9":"39.00000", "fk_livello5":"1.1.1.2.0" } }


来源: stackexchange

问:
PHP How to replace customers text area apostrophes with a escape character
I tried asking this question a week ago but got no answer. Hoping to explain it better this time.

My customer can input anything into a textarea and I am saving that to a MySQL table.

how can I replace all of their apostrophes with a double apostrophe so I don't get a bad query?

I tried the following it didn't work.

```<code>$description = str_replace("''", "'", $description);
</code>```

答:
I think you have problem with function.

```<code>str_replace(find, replace, string, count);
</code>```

and for MySQL you should change all ' to '' so change your code as follow :

```<code>$description = str_replace("'", "''", $description);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I tried asking this question a week ago but got no answer. Hoping to explain it better this time.

My customer can input anything into a textarea and I am saving that to a MySQL table.

how can I replace all of their apostrophes with a double apostrophe so I don't get a bad query?

I tried the following it didn't work.

$description = str_replace("''", "'", $description);

Body:
I think you have problem with function.

str_replace(find, replace, string, count);

and for MySQL you should change all ' to '' so change your code as follow :

$description = str_replace("'", "''", $description);


问:
Is it possible to use the same class in different OCL packages?
I would like to use OCL to link two class diagrams that represent the same model at two levels of abstraction.

To illustrate, consider an abstract model A that contains a class Person that has a 'parents' association to itself. And a more concrete model B, that has classes Person, Male and Female, with Male and Female inheriting from Person, and two associations, one 'father' between Person and Male, and one 'mother' between Person and Female.

I would like to use OCL to link the two models together. That is, I would like to say that 'mother' and 'father' in the concrete model represent the 'parents' association in the abstract model.

I know it is possible to put all the associations in a single model and then to say something like

```<code>context Person inv:
 self.mother->forAll(m | m in self.parents) and
 self.father->forAll(f | f in self.parents) and
 self.parents->forAll(p | p in self.mother or p in self.mother)
</code>```

But I specifically want to separate the models. The idea is that the concrete model does not have to carry the abstractions explicitly with it.

I have thought of using packages to place each model in a separate namespace, but then as far as I can understand, I end up with two different Person classes, one in each package.

Is there a way that I can say that two class names in the different packages represent the same class? that is the same set of objects? for example, would the following expression achieve this or would it simply be always false?

```<code>Abstract::Person.allInstances() = Concrete::Person.allInstances()
</code>```

答:
(RSS suggests that this is a new topic!)

The problem is that you abstract/concrete variants are in some sense different classes, but in another sense the same classes. You must therefore partition your consumers according to whether they want to see abstract/concrete as different/same classes and define what 'same' means for each consumer.

For humans, you can use spelling conventions to make different classes the 'same'. Or annotations or the myriad UML associations.

If you want some degree of functional sameness allowing an 'abstract'/'concrete' class to be used interchangeably in some simulation you perhaps need both 'abstract' and concrete classes to inherit from a shared interface for which you have distinct 'abstract'/'concrete' implementations.

If the sameness is for documentation purposes, you might consider a model transformation language that converts one to the other. Many M2Ms are really just an outer language for OCL providing support for model import/export and mutation. The M2M could capture regular idioms that relate 'abstract' and 'concrete' and might be amenable to mathematical proof and/or automated code generation. It should certainly satisfy requirements tracing necessities.

Body:
I would like to use OCL to link two class diagrams that represent the same model at two levels of abstraction.

To illustrate, consider an abstract model A that contains a class Person that has a 'parents' association to itself. And a more concrete model B, that has classes Person, Male and Female, with Male and Female inheriting from Person, and two associations, one 'father' between Person and Male, and one 'mother' between Person and Female.

I would like to use OCL to link the two models together. That is, I would like to say that 'mother' and 'father' in the concrete model represent the 'parents' association in the abstract model.

I know it is possible to put all the associations in a single model and then to say something like

context Person inv:
 self.mother->forAll(m | m in self.parents) and
 self.father->forAll(f | f in self.parents) and
 self.parents->forAll(p | p in self.mother or p in self.mother)

But I specifically want to separate the models. The idea is that the concrete model does not have to carry the abstractions explicitly with it.

I have thought of using packages to place each model in a separate namespace, but then as far as I can understand, I end up with two different Person classes, one in each package.

Is there a way that I can say that two class names in the different packages represent the same class? that is the same set of objects? for example, would the following expression achieve this or would it simply be always false?

Abstract::Person.allInstances() = Concrete::Person.allInstances()


问:
React-Native Build Error after linking react-native-svg
I've had the error when trying to display a AreaChart in react-native that No View Manager defined for class RNSVGLine and found that for many people linking react-native to react-native-svg solved this issue. For me it just made me achieve a build error.

Unlinking it solves the build problem, but it is back to the previous error.

```<code>import { AreaChart } from 'react-native-svg-charts'
</code>```

This is the import and the package and it is installed using npm.

```<code>return (
        <AreaChart
            style={ { height: 200 } }
            dataPoints={ data }
            fillColor={ 'rgba(134, 65, 244, 0.2)' }
            strokeColor={ 'rgb(134, 65, 244)' }
            contentInset={ { top: 30, bottom: 30 } }
            curve={shape.curveNatural}
        />
    );
</code>```

and this is where I try to render it.

I have no more ideas of what to do, going in the MainApplication.java and manually importing it does not solve the problem for me.

答: The problem was that the compiled library version was not the same as the support library version. This was set in the android/build.gradle and app/build.gradle and in the .json file. After that linking react-native to react-native-svg no longer had the build error and worked.</p>

Body:
I've had the error when trying to display a AreaChart in react-native that No View Manager defined for class RNSVGLine and found that for many people linking react-native to react-native-svg solved this issue. For me it just made me achieve a build error.

Unlinking it solves the build problem, but it is back to the previous error.

import { AreaChart } from 'react-native-svg-charts'

This is the import and the package and it is installed using npm.

return (
        <AreaChart
            style={ { height: 200 } }
            dataPoints={ data }
            fillColor={ 'rgba(134, 65, 244, 0.2)' }
            strokeColor={ 'rgb(134, 65, 244)' }
            contentInset={ { top: 30, bottom: 30 } }
            curve={shape.curveNatural}
        />
    );

and this is where I try to render it.

I have no more ideas of what to do, going in the MainApplication.java and manually importing it does not solve the problem for me.


问:
Regex not removing A-Z and a-z
```<code>String s = "xxx(000) 001";
System.out.println(s.replaceAll("A-Za-z", ""));
</code>```

Why is this printing xxx(000) 001 instead of (000) 001 removing all occurrences from A-Z and a-z?

答:
You are not using a correct regex you have to use a Character classes like this [a-zA-Z]:

```<code>s = s.replaceAll("[a-zA-Z]", "");
</code>```

Title: Regex not removing A-Z and a-z

Body:
String s = "xxx(000) 001";
System.out.println(s.replaceAll("A-Za-z", ""));

Why is this printing xxx(000) 001 instead of (000) 001 removing all occurrences from A-Z and a-z?

Body:
You are not using a correct regex you have to use a Character classes like this [a-zA-Z]:

s = s.replaceAll("[a-zA-Z]", "");

ContentLicense: CC BY-SA 4.0


问:
How to Deserialize this JSON data in C# (asp.net)
How to Deserialize this Json Data in asp.net C#.

```<code>{"USD_PHP":{"2016-12-31":49.560001},"PHP_USD":{"2016-12-31":0.020178}}
</code>```

Here the USD_PHP and PHP_USD is going to be always unique, the Date 2016-12-31 is also unique for every date value. All i want to get the Currency Conversion Rate (49.560001, and 0.020178) in my application. How can i Build the program which is having no Common Key Field?

Source

答:
Deserialize to a Dictionary<string, Dictionary<string, decimal>>.  The outer key will be the currency conversion name, the inner key will be the date, and the value of the inner will be the conversion rate.  This will work with either JavaScriptSerializer or Json.Net.

```<code>string json = @"{""USD_PHP"":{""2016-12-31"":49.560001},""PHP_USD"":{""2016-12-31"":0.020178}}";

var jss = new JavaScriptSerializer();

var outer = jss.Deserialize<Dictionary<string, Dictionary<string, decimal>>>(json);

foreach (var kvp in outer)
{
    foreach (var kvp2 in kvp.Value)
    {
        Console.WriteLine(kvp.Key + "  " + kvp2.Key + "  " + kvp2.Value);
    }
}
</code>```

Output:

```<code>USD_PHP  2016-12-31  49.560001
PHP_USD  2016-12-31  0.020178
</code>```

Fiddle (Json.Net): https://dotnetfiddle.net/L7cvMY

Body:
How to Deserialize this Json Data in asp.net C#.

{"USD_PHP":{"2016-12-31":49.560001},"PHP_USD":{"2016-12-31":0.020178}}

Here the USD_PHP and PHP_USD is going to be always unique, the Date 2016-12-31 is also unique for every date value. All i want to get the Currency Conversion Rate (49.560001, and 0.020178) in my application. How can i Build the program which is having no Common Key Field?

Source

Body:
Deserialize to a Dictionary<string, Dictionary<string, decimal>>.  The outer key will be the currency conversion name, the inner key will be the date, and the value of the inner will be the conversion rate.  This will work with either JavaScriptSerializer or Json.Net.

string json = @"{""USD_PHP"":{""2016-12-31"":49.560001},""PHP_USD"":{""2016-12-31"":0.020178}}";

var jss = new JavaScriptSerializer();

var outer = jss.Deserialize<Dictionary<string, Dictionary<string, decimal>>>(json);

foreach (var kvp in outer)
{
    foreach (var kvp2 in kvp.Value)
    {
        Console.WriteLine(kvp.Key + "  " + kvp2.Key + "  " + kvp2.Value);
    }
}

Output:

USD_PHP  2016-12-31  49.560001
PHP_USD  2016-12-31  0.020178

Fiddle (Json.Net): https://dotnetfiddle.net/L7cvMY


问:
Getting a data attribute with jQuery?
I'm trying to get the data-shareurl from the link below for use in jQuery but for some reason when I put the variable into an alert it is always undefined. Can anyone tell me what I've got wrong? Thanks.
I've made a fiddle here

Html

```<code><a title="" class="fancybox" data-shareurl="www.google.com" href="http://fancyapps.com/fancybox/demo/1_b.jpg">
<img src="http://fancyapps.com/fancybox/demo/1_b.jpg" title="" /></a>
</code>```

jQuery

```<code> var shareurl = $(this).attr('data-shareurl'); //Get this url
 $(".fancybox").fancybox({

   beforeShow: function() {
     this.title = '<div class="addthis addthis_toolbox addthis_default_style "><a href="' + this.href + '" addthis:url="' + this.href + '" addthis:title="' + this.title + '" class="addthis_button_preferred_1"></a></div>';

     alert(shareurl); //see the variable

   },

   afterShow: function() {
     addthis.toolbox(
       $(".addthis").get()
     );
   },
   helpers: {
     title: {
       type: 'inside'
     }
   }

 });
</code>```

答:
Here you go with a solution

$('a').click(function(){
  console.log($(this).data('shareurl'));
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<img src="http://fancyapps.com/fancybox/demo/1_b.jpg" title="" /></code>```

Hope this will help you.

Title: Getting a data attribute with jQuery?

Body:
I'm trying to get the data-shareurl from the link below for use in jQuery but for some reason when I put the variable into an alert it is always undefined. Can anyone tell me what I've got wrong? Thanks.
I've made a fiddle here

Html

jQuery

 var shareurl = $(this).attr('data-shareurl'); //Get this url
 $(".fancybox").fancybox({

   beforeShow: function() {
     this.title = '

';

     alert(shareurl); //see the variable

   },

   afterShow: function() {
     addthis.toolbox(
       $(".addthis").get()
     );
   },
   helpers: {
     title: {
       type: 'inside'
     }
   }

 });

Body:
Here you go with a solution

$('a').click(function(){
  console.log($(this).data('shareurl'));
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a title="" class="fancybox" data-shareurl="www.google.com" href="http://fancyapps.com/fancybox/demo/1_b.jpg">
<img src="http://fancyapps.com/fancybox/demo/1_b.jpg" title="" /></a>

Hope this will help you.


问:
Translating jQuery into Raw Javascript
I have some jQuery code that I would like to change to its raw JavaScript form, and I'm having trouble finding the corresponding elements that make up this jQuery code

```<code>$('.rain').append('<div class="drop" id="drop'+i+'"></div>');
$('#drop'+i).css('left',dropLeft);
$('#drop'+i).css('top',dropTop);
</code>```

I have no idea how to change it back to Javascript, and any help would be greatly appreciated!!

答:
const dropLeft = 5;
const dropTop = 5;
const rain = document.querySelector('.rain');
for (let i = 0; i < 5; i++) {
  let drop = document.createElement('div');
  drop.setAttribute('class', 'drop');
  drop.setAttribute('id', 'drop' + i);
  let dropText = document.createTextNode(i);
  drop.style.left = (dropLeft * i * 10) + 'px';
  drop.style.top = (dropTop * i * 10) + 'px';
  drop.appendChild(dropText);
  rain.appendChild(drop);
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.drop{
position: absolute;
background: blue;
width: 20px;
height:20px;
border-radius: 20px;
color: white;
text-align: center;
}</code>```

```

Title: Translating jQuery into Raw Javascript

Body:
I have some jQuery code that I would like to change to its raw JavaScript form, and I'm having trouble finding the corresponding elements that make up this jQuery code

$('.rain').append('

');
$('#drop'+i).css('left',dropLeft);
$('#drop'+i).css('top',dropTop);

I have no idea how to change it back to Javascript, and any help would be greatly appreciated!!

Body:
const dropLeft = 5;
const dropTop = 5;
const rain = document.querySelector('.rain');
for (let i = 0; i < 5; i++) {
  let drop = document.createElement('div');
  drop.setAttribute('class', 'drop');
  drop.setAttribute('id', 'drop' + i);
  let dropText = document.createTextNode(i);
  drop.style.left = (dropLeft * i * 10) + 'px';
  drop.style.top = (dropTop * i * 10) + 'px';
  drop.appendChild(dropText);
  rain.appendChild(drop);
}

.drop{
position: absolute;
background: blue;
width: 20px;
height:20px;
border-radius: 20px;
color: white;
text-align: center;
}

<div class="rain"></div>


问:
Why the difference between int a[5] = {0} and int a[5]={1} (Missing Feature)
When we initialize an array like this int a[5] = {0}, the compiler makes all 5 elements 0. That is really good, compact-initialization and useful feature.

But I wonder why the compiler doesn't initialize int a[5]={1} similarly? Why does it not make all 5 elements 1? Why the Standard doesn't mandate it? Would it not been an awesome feature? Isn't it missing?

Also, if the number of elements in the initializer is less than the size of the array, then the compile could initialize the remaining elements with the last element in the initializer. Means, int a[5]={1,2,3} is equivalent to int a[5]={1,2,3,3,3}. And similarly, int a[10]={1,2,3,0} is equivalent to int a[10]={1,2,3,0,0,0,0,0,0,0};.

Would it all not be an awesome feature if the Standard mandates it? Or is there any good reasons for this missing feature?

And there is something called designated initializer in C99, which is used like:

Designated initializers can be
  combined with regular initializers, as
  in the following example:

int a[10] = {2, 4, [8]=9, 10}

In this
  example, a[0] is initialized to 2,
  a1 is initialized to 4, a[2] to a[7]
  are initialized to 0, and a[9] is
  initialized to 10.

Quite interesting. But even this feature is not in C++.

答:
Why does it not make all 5 elements 1?

Because you're misunderstanding what {} means. (Actually, in C++ the better way to do this is {} rather than {0}). The syntax {0} does not mean that you want all elements in the aggregate set to zero. Rather, it says that you want an aggregate with the first element zero assigned to the indicated variable (which can be either an array or a class type in C++). Because the aggregate usually has more fields than that one value zero, the remaining elements in the aggregate are default constructed. The default value of a builtin or POD type is to set all of the fields to zero, so you've effectively set the entire aggregate to zero.

As for why specifically, consider the following. According to the current standard, none of the assertions below will fail:

```<code>struct abc
{
    char field1;
    int field2;
    char field3;
};

int main()
{
    abc example = {'a', static_cast<int>('b')};
    //All three asserts pass
    assert(example.field1 == 'a');
    assert(example.field2 == static_cast<int>('b'));
    assert(example.field3 == '\0');

    int example2[3] = {static_cast<int>('a'), 42};
    assert(example2[0] == static_cast<int>('a'));
    assert(example2[1] == 42);
    assert(example2[2] == 0);
}
</code>```

What would you expect the value of field3 to be in your proposed standard change? Even if you define it as the last element in the aggregate initializer as you've shown above, that's going to break compatibility with existing code which assumes the rest of the elements are default constructed.

EDIT: Just realized that your question is asked in terms of arrays - but the answer is the same with either structures or arrays, so it really doesn't matter.

EDIT2: To make this more in keeping with the standard, references to class/structure have been replaced with "aggregate" below, which covers the structures and arrays cases.

ContentLicense: CC BY-SA 2.5

Body:
Why does it not make all 5 elements 1?

Because you're misunderstanding what {} means. (Actually, in C++ the better way to do this is {} rather than {0}). The syntax {0} does not mean that you want all elements in the aggregate set to zero. Rather, it says that you want an aggregate with the first element zero assigned to the indicated variable (which can be either an array or a class type in C++). Because the aggregate usually has more fields than that one value zero, the remaining elements in the aggregate are default constructed. The default value of a builtin or POD type is to set all of the fields to zero, so you've effectively set the entire aggregate to zero.

As for why specifically, consider the following. According to the current standard, none of the assertions below will fail:

struct abc
{
    char field1;
    int field2;
    char field3;
};

int main()
{
    abc example = {'a', static_cast<int>('b')};
    //All three asserts pass
    assert(example.field1 == 'a');
    assert(example.field2 == static_cast<int>('b'));
    assert(example.field3 == '\0');

    int example2[3] = {static_cast<int>('a'), 42};
    assert(example2[0] == static_cast<int>('a'));
    assert(example2[1] == 42);
    assert(example2[2] == 0);
}

What would you expect the value of field3 to be in your proposed standard change? Even if you define it as the last element in the aggregate initializer as you've shown above, that's going to break compatibility with existing code which assumes the rest of the elements are default constructed.

EDIT: Just realized that your question is asked in terms of arrays - but the answer is the same with either structures or arrays, so it really doesn't matter.

EDIT2: To make this more in keeping with the standard, references to class/structure have been replaced with "aggregate" below, which covers the structures and arrays cases.


问:
How do I get the latest version of my code?
I'm using Git 1.7.4.1.

I want to get the latest version of my code from the repository, but I'm getting errors:

```<code>$ git pull
….
M   selenium/ant/build.properties
….
M   selenium/scripts/linux/get_latest_updates.sh
M   selenium/scripts/windows/start-selenium.bat
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as appropriate to mark resolution, or use 'git commit -a'.
</code>```

I've deleted the local copies of the files the tool is complaining about, but I still get the errors.

How do I check out the latest version from the remote repository?

答:
try this code</p>

```<code>cd /go/to/path
git pull origin master
</code>```

Body:
I'm using Git 1.7.4.1.

I want to get the latest version of my code from the repository, but I'm getting errors:

$ git pull
….
M   selenium/ant/build.properties
….
M   selenium/scripts/linux/get_latest_updates.sh
M   selenium/scripts/windows/start-selenium.bat
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as appropriate to mark resolution, or use 'git commit -a'.

I've deleted the local copies of the files the tool is complaining about, but I still get the errors.

How do I check out the latest version from the remote repository?

Body:
try this code

cd /go/to/path
git pull origin master


问:
how to delete email address from table in phpmyadmin
I wanted to delete the email address of the customer in phpmyadmin, using php and html. The delete button is working, but it doesn't delete the email address at all.

I'm still new in learning php language. So, there might be some parts I might have done wrong.

I made 3 pages; account.php, deleteemail.php and delete.php

This is the php code for account.php

```<code><?php

        mysql_connect("localhost", "root","") or die(mysql_error());
        mysql_select_db("eib_clicks") or die("Cannot connect to database");
        $query = mysql_query("SELECT * FROM customer_ai WHERE username='$user' LIMIT 1");
        while($row = mysql_fetch_array($query))
        {
            Print "<tr>";

                Print '<td align="center">'. $row['username'] . "</td>";
                Print '<td align="center">'. $row['name'] . "</td>";
                Print '<td align="center">'. $row['address'] . "</td>";
                Print '<td align="center">'. $row['secondaddress'] . "</td>";
                Print '<td align="center"><a href="addaddress.php?username='. $row['username'] .'">add</a> </td>';
                Print '<td align="center">'. $row['email'] . "</td>";
                Print '<td align="center"><a href="editemail.php?username='. $row['username'] .'">edit</a> </td>';
                Print '<td align="center"><a href="deleteemail.php?username='. $row['username'] .'">delete</a> </td>';
                Print '<td align="center">'. $row['type'] . "</td>";
                Print '<td align="center">'. $row['public'] . "</td>";
                Print '<td align="center"><a href="editpublic.php?username='. $row['username'] .'">edit</a> </td>';
            Print "</tr>";
        }
    ?>
</code>```

This one works just fine.

Php code for deleteemail.php

```<code><?php
session_start();
if($_SESSION['user']){
}
else{
    header("location:account.php");
}
$user = $_SESSION['user'];
$id_exists = false;
?>
</code>```

Second part of the code;

```<code><?php

                mysql_connect("localhost", "root", "") or die(mysql_error());
                mysql_select_db("eib_clicks") or die("Cannot connect to database");
                $query = mysql_query("Select * from customer_ai Where username='$user'");
                $count = mysql_num_rows($query);
                if($count > 0)
                {
                    while($row = mysql_fetch_array($query))
                    {
                        Print "<tr>";
                            Print '<td align="center">'. $row['email'] . "</td>";

                        Print "</tr>";
                    }
                }

            ?>
</code>```

Third part of the code;

```<code><?php

        Print '
        <a href="delete.php" class="btn btn-sm btn-danger" role="button" onclick="myFunction('.$row['username'] .')">Delete</a>

        ';

        ?>
</code>```

I add script in this page too;

```<code><script>
    function myFunction(username)
    {
    var r=confirm("Are you sure you want to delete this email?");
    if(r==true)
        {
            window.location.assign("deleteemail.php?username=" + username);
        }
    }
</script>
</code>```

Lastly php code for delete.php

```<code><?php
    session_start();
    if($_SESSION['user']){
    }
    else{
        header("location:homepage.php");
    }

    if($_SERVER['REQUEST_METHOD'] == "GET")
    {
        mysql_connect("localhost", "root","") or die(mysql_error());
        mysql_select_db("eib_clicks") or die("Cannot connect to database");

        mysql_query("DELETE FROM account_ai WHERE $email=['email']");

        header("location: account.php");
    }
?>
</code>```

I tried everything on the delete.php but nothing works. The rest of the codes works fine. I used $row['id'] but it deletes the whole row. I only wanted to delete the email address not the whole row. Please help me.

This is how my customer_ai table looks like;

table for customer_ai

答:
What you want to do is UPDATE, not DELETE.  You want to set the value of the email to NULL. UPDATE customer_ai SET email = NULL WHERE username = some_username  Replace some_username with your php.

Edit: I noticed your code has acccount_ai, but your screenshot is customer_ai so I used customer_ai.

Body:
I wanted to delete the email address of the customer in phpmyadmin, using php and html. The delete button is working, but it doesn't delete the email address at all.

I'm still new in learning php language. So, there might be some parts I might have done wrong.

I made 3 pages; account.php, deleteemail.php and delete.php

This is the php code for account.php

<?php

        mysql_connect("localhost", "root","") or die(mysql_error());
        mysql_select_db("eib_clicks") or die("Cannot connect to database");
        $query = mysql_query("SELECT * FROM customer_ai WHERE username='$user' LIMIT 1");
        while($row = mysql_fetch_array($query))
        {
            Print "
";

                Print ''. $row['username'] . "	";
                Print ''. $row['name'] . "	";
                Print ''. $row['address'] . "	";
                Print ''. $row['secondaddress'] . "	";
                Print 'add 	';
                Print ''. $row['email'] . "	";
                Print 'edit 	';
                Print 'delete 	';
                Print ''. $row['type'] . "	";
                Print ''. $row['public'] . "	";
                Print 'edit 	';
            Print "
";
        }
    ?>

This one works just fine.

Php code for deleteemail.php

<?php
session_start();
if($_SESSION['user']){
}
else{
    header("location:account.php");
}
$user = $_SESSION['user'];
$id_exists = false;
?>

Second part of the code;

<?php

                mysql_connect("localhost", "root", "") or die(mysql_error());
                mysql_select_db("eib_clicks") or die("Cannot connect to database");
                $query = mysql_query("Select * from customer_ai Where username='$user'");
                $count = mysql_num_rows($query);
                if($count > 0)
                {
                    while($row = mysql_fetch_array($query))
                    {
                        Print "
";
                            Print ''. $row['email'] . "	";

                        Print "
";
                    }
                }

            ?>

Third part of the code;

<?php

        Print '
        Delete

        ';

        ?>

I add script in this page too;

Lastly php code for delete.php

<?php
    session_start();
    if($_SESSION['user']){
    }
    else{
        header("location:homepage.php");
    }

    if($_SERVER['REQUEST_METHOD'] == "GET")
    {
        mysql_connect("localhost", "root","") or die(mysql_error());
        mysql_select_db("eib_clicks") or die("Cannot connect to database");

        mysql_query("DELETE FROM account_ai WHERE $email=['email']");

        header("location: account.php");
    }
?>

I tried everything on the delete.php but nothing works. The rest of the codes works fine. I used $row['id'] but it deletes the whole row. I only wanted to delete the email address not the whole row. Please help me.

This is how my customer_ai table looks like;

table for customer_ai


答:
Just paste this:

delete.php

```<code><?php
    session_start();
    if($_SESSION['user']){
    }
    else{
        header("location:homepage.php");
    }

    if($_SERVER['REQUEST_METHOD'] == "GET")
    {
          $username = $_GET['username'];
        mysql_connect("localhost", "root","") or die(mysql_error());
        mysql_select_db("eib_clicks") or die("Cannot connect to database");

        mysql_query("UPDATE account_ai SET email = '' WHERE username = '$username'");

        header("location: account.php");
    }
?>
</code>```

Title: how to delete email address from table in phpmyadmin

Body:
Just paste this:

delete.php

<?php
    session_start();
    if($_SESSION['user']){
    }
    else{
        header("location:homepage.php");
    }

    if($_SERVER['REQUEST_METHOD'] == "GET")
    {
          $username = $_GET['username'];
        mysql_connect("localhost", "root","") or die(mysql_error());
        mysql_select_db("eib_clicks") or die("Cannot connect to database");

        mysql_query("UPDATE account_ai SET email = '' WHERE username = '$username'");

        header("location: account.php");
    }
?>


问:
How to display notification like this or with IMPORTANCE_UNSPECIFIED?
How to display notification like Quality Time. I use the below code to display notification but it give me IllegalArgumentException: Invalid importance level

```<code>mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
CharSequence name = getString(R.string.app_name);
// Create the channel for the notification
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name,
        NotificationManager.IMPORTANCE_UNSPECIFIED);

// Set the Notification Channel for the Notification Manager.
mNotificationManager.createNotificationChannel(mChannel);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
        .setContentTitle(getString(R.string.app_name))
        .setAutoCancel(true);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(
        this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);

builder.setContentIntent(contentIntent);

Notification notification = builder.build();
startForeground(1, notification);
</code>```

Get this error :

```<code>java.lang.IllegalArgumentException: Invalid importance level
at android.os.Parcel.readException(Parcel.java:1950)
at android.app.INotificationManager$Stub$Proxy.createNotificationChannels(INotificationManager.java:1556)
at android.app.NotificationManager.createNotificationChannels(NotificationManager.java:453)
at android.app.NotificationManager.createNotificationChannel(NotificationManager.java:441)
at com.app.MyService.onCreate(ScreenService.java:167) –
Add Comment Collapse
</code>```

答:
You should use NotificationManager.IMPORTANCE_MIN

IMPORTANCE_MIN

added in API level 24
int IMPORTANCE_MIN
Only shows in the shade, below the fold.

https://developer.android.com/reference/android/app/NotificationManager.html#IMPORTANCE_MIN

Body:
How to display notification like Quality Time. I use the below code to display notification but it give me IllegalArgumentException: Invalid importance level

mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
CharSequence name = getString(R.string.app_name);
// Create the channel for the notification
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name,
        NotificationManager.IMPORTANCE_UNSPECIFIED);

// Set the Notification Channel for the Notification Manager.
mNotificationManager.createNotificationChannel(mChannel);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
        .setContentTitle(getString(R.string.app_name))
        .setAutoCancel(true);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(
        this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);

builder.setContentIntent(contentIntent);

Notification notification = builder.build();
startForeground(1, notification);

Get this error :

java.lang.IllegalArgumentException: Invalid importance level
at android.os.Parcel.readException(Parcel.java:1950)
at android.app.INotificationManager$Stub$Proxy.createNotificationChannels(INotificationManager.java:1556)
at android.app.NotificationManager.createNotificationChannels(NotificationManager.java:453)
at android.app.NotificationManager.createNotificationChannel(NotificationManager.java:441)
at com.app.MyService.onCreate(ScreenService.java:167) –
Add Comment Collapse


问:
how to move object using path geometry by clicking a button?
I try a Path geometry to move my image in curve path using WPF. However, when i click the 'Start' button,the canvas itself moving in the path, not the image. So how i am going to move the image by clicking a 'Start' button? Below are codes that  have done.

This is my xaml code:

```<code>     <Window x:Class="WpfAppPoint4.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfAppPoint4"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
   <Storyboard x:Key="Storyboard1">
        <MatrixAnimationUsingPath
            Storyboard.TargetProperty="RenderTransform.(MatrixTransform.Matrix)"
                Duration="0:0:5" DoesRotateWithTangent="True">
            <MatrixAnimationUsingPath.PathGeometry>
                <PathGeometry Figures="M0,0 L50,0 A100,100 0 0 1 150,100
                                           A50,50 0 1 1 100,50 L200,50"/>
            </MatrixAnimationUsingPath.PathGeometry>
        </MatrixAnimationUsingPath>
    </Storyboard>

</Window.Resources>
<Grid>
   <Canvas Name="MyCanvas" Margin="4,10,-4,-10">
   <Button x:Name="button_Start" Content="Start" HorizontalAlignment="Right"
   VerticalAlignment="Top" Width="150" Click="Button_Start"
   Canvas.Right="320" Canvas.Top="553" Height="45" FontFamily="Microsoft
   Sans Serif" FontSize="20">
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <BeginStoryboard Storyboard="{StaticResource
                     Storyboard1}"/>
                </EventTrigger>
            </Button.Triggers>
        </Button>

      <Image Source="C:\Users\Merlinz\Downloads\Kid-Tap\Kid-Tap\parent.png"
             x:Name="ParentNode" Width="40" Height="40" Canvas.Top="100"
             Canvas.Left="5"

RenderTransformOrigin="0.5,0.5">
   <Image.RenderTransform>
        <TransformGroup>
            <MatrixTransform/>
        </TransformGroup>

    </Image.RenderTransform>

        </Image>
    </Grid>
</Canvas>
</code>```

答:
In order to make the animation work on the Image element, you have to set the Storyboard.TargetName property.

Besides that, when you want to animate a MatrixTransform in the RenderTransform property of an element, you must not put the MatrixTransform in a TransformGroup.

So change your Image declaration to this:

```<code><Image x:Name="movingImage" ...>
    <Image.RenderTransform>
        <MatrixTransform/>
    </Image.RenderTransform>
</Image>
</code>```

an animate it like this (where the property path RenderTransform.Matrix is equivalent to yours, but shorter):

```<code><MatrixAnimationUsingPath
    Storyboard.TargetProperty="RenderTransform.Matrix"
    Storyboard.TargetName="movingImage" ...>
    ...
</MatrixAnimationUsingPath>
</code>```

Body:
I try a Path geometry to move my image in curve path using WPF. However, when i click the 'Start' button,the canvas itself moving in the path, not the image. So how i am going to move the image by clicking a 'Start' button? Below are codes that  have done.

This is my xaml code:

     <Window x:Class="WpfAppPoint4.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfAppPoint4"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
   <Storyboard x:Key="Storyboard1">
        <MatrixAnimationUsingPath
            Storyboard.TargetProperty="RenderTransform.(MatrixTransform.Matrix)"
                Duration="0:0:5" DoesRotateWithTangent="True">
            <MatrixAnimationUsingPath.PathGeometry>
                <PathGeometry Figures="M0,0 L50,0 A100,100 0 0 1 150,100
                                           A50,50 0 1 1 100,50 L200,50"/>
            </MatrixAnimationUsingPath.PathGeometry>
        </MatrixAnimationUsingPath>
    </Storyboard>

</Window.Resources>
<Grid>
   <Canvas Name="MyCanvas" Margin="4,10,-4,-10">
   <Button x:Name="button_Start" Content="Start" HorizontalAlignment="Right"
   VerticalAlignment="Top" Width="150" Click="Button_Start"
   Canvas.Right="320" Canvas.Top="553" Height="45" FontFamily="Microsoft
   Sans Serif" FontSize="20">
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <BeginStoryboard Storyboard="{StaticResource
                     Storyboard1}"/>
                </EventTrigger>
            </Button.Triggers>
        </Button>

      <Image Source="C:\Users\Merlinz\Downloads\Kid-Tap\Kid-Tap\parent.png"
             x:Name="ParentNode" Width="40" Height="40" Canvas.Top="100"
             Canvas.Left="5"

RenderTransformOrigin="0.5,0.5">
   <Image.RenderTransform>
        <TransformGroup>
            <MatrixTransform/>
        </TransformGroup>

    </Image.RenderTransform>

        </Image>
    </Grid>
</Canvas>

Body:
In order to make the animation work on the Image element, you have to set the Storyboard.TargetName property.

Besides that, when you want to animate a MatrixTransform in the RenderTransform property of an element, you must not put the MatrixTransform in a TransformGroup.

So change your Image declaration to this:

<Image x:Name="movingImage" ...>
    <Image.RenderTransform>
        <MatrixTransform/>
    </Image.RenderTransform>
</Image>

an animate it like this (where the property path RenderTransform.Matrix is equivalent to yours, but shorter):

<MatrixAnimationUsingPath
    Storyboard.TargetProperty="RenderTransform.Matrix"
    Storyboard.TargetName="movingImage" ...>
    ...
</MatrixAnimationUsingPath>


问:
How can i remove currency sign on amount before uploading to database?
Before it get's inserted to sql database the currency sign on amount is already removed.</p>

答:
You can use substr(). If the sign is in front of the amount, you just have to set the start value to 1. If the sign is behind the amount, you set the start value to 0 and the length value to the length of the amount.

For example:
Sign in front of amount:
substr("¥100",1);
Sign after amount:
substr("100€",0,3);


问:
Multiple inserts in a loop codeigniter
Let's say in my DB i have 2 tables. One is named Father with Father_id as PK and Father_name as a row. Then i have the second table as Children with Child_id as PK, Father_id as FK, and Child_name as a row.

Children would have a relationship with Father as Many to One. Many Children to One Father.

So let's say the data looks like this in my controller.

```<code>Array([Father_id] => 1 [Children] => Array([0] => John [1] => Peter [2] => Michael))
</code>```

I pass the data above to my model to insert right but i have to restructure it in a way that i can just send it to my database to insert.

```<code>foreach($data as $row){
    for($temp = 0; $temp < count($data['Child_name']); $temp++){
        $query[$temp] = array('Father_id' => $data['Father_id'], 'child_name' => $row[$temp]);
    }
}
</code>```

So now it looks like this,

```<code>Array([0]=>Array([Father_id] => 1 [Child_name] => John)[1]=>Array([Father_id] => 1 [Child_name] => Peter)[2]=>Array([Father_id] => 1 [Child_name] => Michael))
</code>```

I understand how to insert this, i'll just have to do another foreach loop or i can just remove the $temp in $query[$temp] and instead put an insert query inside that loop.

My problem is that how can i know that each insert is successful, other than checking the database, i would like to have a return statement like if its only a single insert then if its successful it returns 1.

Also is there any better way to do multiple inserts?

UPDATE:

After some needed break i came back and made some changes.

This is now my model function:

```<code>        public function insert_children($data){
        foreach($data['child_name'] as $row){
            $query = array('father_id' => $data['father_id'], 'child_name' => $row);
            $result = $this->db->insert('children',$query);
        }
  //return something here
}
</code>```

It is essential to return something back to the controller right? for example, i want to return if the inserts were successful or not. So is there any already made function in codeigniter for this? or do i have to make myself.

for example, i can just make a $temp variable to contain an incremental value each time an insert is successful and compare it at the end of the loop to the count($data['children'])

So if there are 3 children the value of $temp should be 3 or 2 depending on declaration if i specify it with 1 like $temp = 1;

答:
A General way to insert multiple data</p>

```<code>$data = array(
    array('father_id'=> 'id', 'child_name' => 'Unni' ),
    array('father_id'=> 'id', 'child_name' => 'Kuttan' ),
    //...
);

$this->db->insert('mytable', $data);
</code>```

Title: Multiple inserts in a loop codeigniter

Body:
Let's say in my DB i have 2 tables. One is named Father with Father_id as PK and Father_name as a row. Then i have the second table as Children with Child_id as PK, Father_id as FK, and Child_name as a row.

Children would have a relationship with Father as Many to One. Many Children to One Father.

So let's say the data looks like this in my controller.

Array([Father_id] => 1 [Children] => Array([0] => John [1] => Peter [2] => Michael))

I pass the data above to my model to insert right but i have to restructure it in a way that i can just send it to my database to insert.

foreach($data as $row){
    for($temp = 0; $temp < count($data['Child_name']); $temp++){
        $query[$temp] = array('Father_id' => $data['Father_id'], 'child_name' => $row[$temp]);
    }
}

So now it looks like this,

Array([0]=>Array([Father_id] => 1 [Child_name] => John)[1]=>Array([Father_id] => 1 [Child_name] => Peter)[2]=>Array([Father_id] => 1 [Child_name] => Michael))

I understand how to insert this, i'll just have to do another foreach loop or i can just remove the $temp in $query[$temp] and instead put an insert query inside that loop.

My problem is that how can i know that each insert is successful, other than checking the database, i would like to have a return statement like if its only a single insert then if its successful it returns 1.

Also is there any better way to do multiple inserts?

UPDATE:

After some needed break i came back and made some changes.

This is now my model function:

        public function insert_children($data){
        foreach($data['child_name'] as $row){
            $query = array('father_id' => $data['father_id'], 'child_name' => $row);
            $result = $this->db->insert('children',$query);
        }
  //return something here
}

It is essential to return something back to the controller right? for example, i want to return if the inserts were successful or not. So is there any already made function in codeigniter for this? or do i have to make myself.

for example, i can just make a $temp variable to contain an incremental value each time an insert is successful and compare it at the end of the loop to the count($data['children'])

So if there are 3 children the value of $temp should be 3 or 2 depending on declaration if i specify it with 1 like $temp = 1;

Body:
A General way to insert multiple data

$data = array(
    array('father_id'=> 'id', 'child_name' => 'Unni' ),
    array('father_id'=> 'id', 'child_name' => 'Kuttan' ),
    //...
);

$this->db->insert('mytable', $data);


问:
SQL Joins vs Single Table : Performance Difference?
I am trying to stick to the practice of keeping the database normalized, but that leads to the need to run multiple join queries. Is there a performance degradation if many queries use joins vs having a call to a single table that might contain redundant data?</p>

答:
We leave query optimisation up to the database for the same reasons we leave code optimisation up to the compiler.

Most modern RDBMSes are pretty good in this respect these days.

Before you think that denormalisation is 'ok' in some cases, consider this: normally you are not interested in every attribute. Therefore loading unneeded data off the disk is inefficient (typically the least efficient component of the database). This can be much worse if you have a denormalised design, with lots of redundant data in a row. Even worse again if you have to then update all that redundant data. It can be much more efficient to load some narrow tables containing only the columns of interest and join them. Again, this depends on the database, so without profiling you have no clue.

If you are really worried about performance, you're probably talking scalability issues. In this case you might want to look at sharding, for which proper (normalised) schema design is important.

OwnerDisplayName: zsharp

LastEditorDisplayName: mwigdahl


问:
Obj-C/AppleScript syntax problem
I'm calling an AppleScript from inside my application. The relevant snippet of my code looks like so:

```<code>-(void)sendMail:(NSString*)addressStr
    {
    NSString *scriptString = <snip>
    @"end tell\n"
    @"tell b to make new to recipient with properties {address:\"someone@somewhere.com\"}\n"
    @"send b\n"
    @"end tell\n";
    <snip>
}
</code>```

The script with "hard-wired" email address runs perfectly, but I really want to use addresses out of our community database. I tried using a mutable string for the scriptString, then inserting the passed addressStr into it at an exact (known) index before passing scriptString to the AppleScript object. But if I remove (only) the address chars and try something like:

```<code>@"tell b to make new to recipient with properties {address:\"\"}\n"
<snip>
[scriptString insertString:addressStr atIndex:556];
</code>```

...it either won't compile or gives an "Attempt to mutate immutable object (??) with insertString:atIndex:" error at runtime -- depending on what I try.

So either my syntax is wrong (P=0.95), or I'm trying to do the impossible with AppleScript. Can anyone help me out, please? Thanks a lot in advance :-)

答: You need to use [NSString stringWithFormat:@"... %@ ...", @"arg"].

Title: Obj-C/AppleScript syntax problem

Body:
I'm calling an AppleScript from inside my application. The relevant snippet of my code looks like so:

-(void)sendMail:(NSString*)addressStr
    {
    NSString *scriptString = <snip>
    @"end tell\n"
    @"tell b to make new to recipient with properties {address:\"someone@somewhere.com\"}\n"
    @"send b\n"
    @"end tell\n";
    <snip>
}

The script with "hard-wired" email address runs perfectly, but I really want to use addresses out of our community database. I tried using a mutable string for the scriptString, then inserting the passed addressStr into it at an exact (known) index before passing scriptString to the AppleScript object. But if I remove (only) the address chars and try something like:

@"tell b to make new to recipient with properties {address:\"\"}\n"
<snip>
[scriptString insertString:addressStr atIndex:556];

...it either won't compile or gives an "Attempt to mutate immutable object (??) with insertString:atIndex:" error at runtime -- depending on what I try.

So either my syntax is wrong (P=0.95), or I'm trying to do the impossible with AppleScript. Can anyone help me out, please? Thanks a lot in advance :-)


问:
What other <tag> can be use to fire AJAX other than <button>?
I have a menu below:

<button class="bu" value="orange">Orange</button>

<button class="bu" value="apple">Apple</button>

```
</div>
</div>
</p>

<p>Instead of link, I add EventListener script:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><script>
var bs = document.getElementsByClassName("bu");
for(var i =0; i< bs.length; i++){
bs[i].addEventListener('click', function(){ sFunction(this.value);});
}
</script></code>```

When clicked it will call the ajax function below:

function sFunction(value) {
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","some.php?q="+value,true);
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {document.getElementById("ajax").innerHTML = xmlhttp.responseText;}}}```

This code is working nicely. I believe it is because 'button' support the VALUE attribute which 'li' doesn't.

Now, if I don't want to use 'button', is there any other tag/element I can use to replace 'button'?

My logic is that I don't want use button to fire ajax in my menu because the button will appear on the list menu.

Any suggestion?

答:
it can be any element, like div, span etc,, but the only thing that you need to be aware is where will you have your value saved.

If it was button you had it in value tag, and if you for example use div we can have it in custom tag like this,,

var bs = document.getElementsByClassName("bu");
for (var i = 0; i < bs.length; i++) {
  bs[i].addEventListener('click', function() {
    sFunction(this.getAttribute('data-value'));
  });
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="bu" data-value="42">Value</div></code>```

So note that instead to pass this.value to your ajax function, we only changed that to

```<code>sFunction( this.getAttribute('data-value') );
</code>```

Hope that helps you

Body:
I have a menu below:

<button class="bu" value="orange">Orange</button>

<button class="bu" value="apple">Apple</button>

Instead of link, I add EventListener script:

When clicked it will call the ajax function below:

function sFunction(value) {
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","some.php?q="+value,true);
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {document.getElementById("ajax").innerHTML = xmlhttp.responseText;}}}

This code is working nicely. I believe it is because 'button' support the VALUE attribute which 'li' doesn't.

Now, if I don't want to use 'button', is there any other tag/element I can use to replace 'button'?

My logic is that I don't want use button to fire ajax in my menu because the button will appear on the list menu.

Any suggestion?

Body:
it can be any element, like div, span etc,, but the only thing that you need to be aware is where will you have your value saved.

If it was button you had it in value tag, and if you for example use div we can have it in custom tag like this,,

var bs = document.getElementsByClassName("bu");
for (var i = 0; i < bs.length; i++) {
  bs[i].addEventListener('click', function() {
    sFunction(this.getAttribute('data-value'));
  });
}

<div class="bu" data-value="42">Value</div>

So note that instead to pass this.value to your ajax function, we only changed that to

sFunction( this.getAttribute('data-value') );

Hope that helps you


问:
Error with rendering two queries - express mongo
I have a problem with rendering two queries from mongo database into the ejs file.

Here is my request

```<code>Diveplace
    .find({})
    .skip((perPage * page) - perPage)
    .limit(perPage)
    .exec(function(err, foundDiveplace) {
        Diveplace.count().exec(function(err, count) {
            if (err) return next(err)
Country.find({}, function(err, foundCountry){
  var returnVals= JSON.stringify({diveplaces: foundDiveplace, countries: foundCountry});

   res.render('diveplaces/index', {
                data: returnVals,
                country: foundCountry,
                current: page,
                pages: Math.ceil(count / perPage),
                          currentUser: req.user
            })
        })
    })
})
</code>```

}
})

I try to display it on ejs page by just

```<code><%= data %>
</code>```

And it shows me whole JSON object. When i try to get deeper - data.diveplaces it gives me an error undefined.

How i can extract data from that JSON and display it? I think it's abit diffrent than single render

答:
Nvm. Fixed it. The problem was, the JSON wasn't actually JSON.

JSON.parse(data) helped

Body:
I have a problem with rendering two queries from mongo database into the ejs file.

Here is my request

Diveplace
    .find({})
    .skip((perPage * page) - perPage)
    .limit(perPage)
    .exec(function(err, foundDiveplace) {
        Diveplace.count().exec(function(err, count) {
            if (err) return next(err)
Country.find({}, function(err, foundCountry){
  var returnVals= JSON.stringify({diveplaces: foundDiveplace, countries: foundCountry});

   res.render('diveplaces/index', {
                data: returnVals,
                country: foundCountry,
                current: page,
                pages: Math.ceil(count / perPage),
                          currentUser: req.user
            })
        })
    })
})

}
})

I try to display it on ejs page by just

<%= data %>

And it shows me whole JSON object. When i try to get deeper - data.diveplaces it gives me an error undefined.

How i can extract data from that JSON and display it? I think it's abit diffrent than single render


问:
How to debug kubectl apply for kube-flannel.yml?
I'm trying to create a kubernetes cluster following the document at: https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/

First I have installed kubeadm with docker image on Coreos (1520.9.0) inside VirtualBox with Vagrant:

```<code>docker run -it \
    -v /etc:/rootfs/etc \
    -v /opt:/rootfs/opt \
    -v /usr/bin:/rootfs/usr/bin \
    -e K8S_VERSION=v1.8.4 \
    -e CNI_RELEASE=v0.6.0 \
    xakra/kubeadm-installer:0.4.7 coreos
</code>```

This was my kubeadm init:

kubeadm init --pod-network-cidr=10.244.0.0/16

When run the command:

```<code>kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml
</code>```

It returns:

```<code>clusterrole "flannel" configured
clusterrolebinding "flannel" configured
serviceaccount "flannel" configured
configmap "kube-flannel-cfg" configured
daemonset "kube-flannel-ds" configured
</code>```

But if I check "kubectl get pods --all-namespaces"

It returns:

```<code>NAMESPACE     NAME                              READY     STATUS             RESTARTS   AGE
kube-system   etcd-coreos1                      1/1       Running            0          18m
kube-system   kube-apiserver-coreos1            1/1       Running            0          18m
kube-system   kube-controller-manager-coreos1   0/1       CrashLoopBackOff   8          19m
kube-system   kube-scheduler-coreos1            1/1       Running            0          18m
</code>```

With journalctl -f -u kubelet I can see this error: Unable to update cni config: No networks found in /etc/cni/net.d

I suspect that something was wrong with the command kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml

Is there a way to know why this command doesn't work? Can I get some logs from anywhere?

答:
Just tonight I used kubespray to provision a vagrant cluster, on CoreOS, using flannel (vxlan), and I was also mystified about how flannel could be a Pod inside Kubernetes

It turns out, as seen here, that they are using flannel-cni image from quay.io to write out CNI files using a flannel side-car plus hostDir volume-mounts; it outputs cni-conf.json (that configures CNI to use flannel), and then net-conf.json (that configures the subnet and backend used by flannel).

I hope the jinja2 mustache syntax doesn't obfuscate the answer, but I found it very interesting to see how the Kubernetes folks chose to do it "for real" to compare and contrast against the example DaemonSet given in the flannel-cni README. I guess that's the long way of saying: try the descriptors in the flannel-cni README, then if it doesn't work see if they differ in some way from the known-working kubespray setup

update: as a concrete example, observe that the Documentation yaml doesn't include the --iface= switch, and if your Vagrant setup is using both NAT and "private_network" then it likely means flannel is binding to eth0 (the NAT one) and not eth1 with a more static IP. I saw that caveat mentioned in the docs, but can't immediately recall where in order to cite it

update 2

Is there a way to know why this command doesn't work? Can I get some logs from anywhere?

One may almost always access the logs of a Pod (even a statically defined one such as kube-controller-manager-coreos1) in the same manner: kubectl --namespace=kube-system logs kube-controller-manager-coreos1, and in the CrashLoopBackOff circumstance, adding in the -p for "-p"revious will show the logs from the most recent crash (but only for a few seconds, not indefinitely), and occasionally kubectl --namespace=kube-system describe pod kube-controller-manager-coreos1 will show helpful information in either the Events section at the bottom, or in the "Status" block near the top if it was Terminated for cause

In the case of a very bad failure, such as the apiserver failing to come up (and thus kubectl logs won't do anything), then ssh-ing to the Node and using a mixture of journalctl -u kubelet.service --no-pager --lines=150 and docker logs ${the_sha_or_name} to try and see any error text. You will almost certainly need docker ps -a in the latter case to find the exited container's sha or name, but that same "only for a few seconds" applies, too, as dead containers will be pruned after some time.

In the case of vagrant, one can ssh into the VM in one of several ways:

vagrant ssh coreos1

vagrant ssh-config > ssh-config && ssh -F ssh-config coreos1

or if it has a "private_network" address, such as 192.168.99.101 or such, then you can usually ssh -i ~/.vagrant.d/insecure_private_key core@192.168.99.101 but one of the first two are almost always more convenient

Body:
I'm trying to create a kubernetes cluster following the document at: https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/

First I have installed kubeadm with docker image on Coreos (1520.9.0) inside VirtualBox with Vagrant:

docker run -it \
    -v /etc:/rootfs/etc \
    -v /opt:/rootfs/opt \
    -v /usr/bin:/rootfs/usr/bin \
    -e K8S_VERSION=v1.8.4 \
    -e CNI_RELEASE=v0.6.0 \
    xakra/kubeadm-installer:0.4.7 coreos

This was my kubeadm init:

kubeadm init --pod-network-cidr=10.244.0.0/16

When run the command:

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml

It returns:

clusterrole "flannel" configured
clusterrolebinding "flannel" configured
serviceaccount "flannel" configured
configmap "kube-flannel-cfg" configured
daemonset "kube-flannel-ds" configured

But if I check "kubectl get pods --all-namespaces"

It returns:

NAMESPACE     NAME                              READY     STATUS             RESTARTS   AGE
kube-system   etcd-coreos1                      1/1       Running            0          18m
kube-system   kube-apiserver-coreos1            1/1       Running            0          18m
kube-system   kube-controller-manager-coreos1   0/1       CrashLoopBackOff   8          19m
kube-system   kube-scheduler-coreos1            1/1       Running            0          18m

With journalctl -f -u kubelet I can see this error: Unable to update cni config: No networks found in /etc/cni/net.d

I suspect that something was wrong with the command kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml

Is there a way to know why this command doesn't work? Can I get some logs from anywhere?


问:
HTML Page not displaying using Python Socket Programming
I'm trying to learn socket programming with python, and I've created a simple webserver, and I can connect to it in my browswer. I've opened an html file and send it, but it's not displaying in the browswer.

My simple webserver

```<code>import socket
import os

# Standard socket stuff:
host = ''
port = 8080
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((host, port))
sock.listen(5)

# Loop forever, listening for requests:
while True:
    csock, caddr = sock.accept()
    print("Connection from: " + str(caddr))
    req = csock.recv(1024)  # get the request, 1kB max
    print(req)
    # Look in the first line of the request for a move command
    # A move command should be e.g. 'http://server/move?a=90'
    filename = 'static/index.html'
    f = open(filename, 'r')
    l = f.read(1024)
    while (l):
        csock.sendall(str.encode("""HTTP/1.0 200 OK\n""",'iso-8859-1'))
        csock.sendall(str.encode('Content-Type: text/html\n', 'iso-8859-1'))
        csock.send(str.encode('\n'))
        csock.sendall(str.encode(""+l+"", 'iso-8859-1'))
        print('Sent ', repr(l))
        l = f.read(1024)
    f.close()

    csock.close()
</code>```

index.html

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Title</title>

This is the body

```

I'm very new at this, so I'm probably just missing a very minute details, but I'd love some help on getting the html file to correctly display in the browser.

答:
I've tried your script works fine by the way.
Maybe you need to check the filename value.

note: little change to make sure all strings on html file sent.

```<code>import socket
import os

# Standard socket stuff:
host = ''
port = 8080
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((host, port))
sock.listen(5)

# Loop forever, listening for requests:
while True:
    csock, caddr = sock.accept()
    print("Connection from: " + str(caddr))
    req = csock.recv(1024)  # get the request, 1kB max
    print(req)
    # Look in the first line of the request for a move command
    # A move command should be e.g. 'http://server/move?a=90'
    filename = 'static/index.html'
    f = open(filename, 'r')

    csock.sendall(str.encode("HTTP/1.0 200 OK\n",'iso-8859-1'))
    csock.sendall(str.encode('Content-Type: text/html\n', 'iso-8859-1'))
    csock.send(str.encode('\r\n'))
    # send data per line
    for l in f.readlines():
        print('Sent ', repr(l))
        csock.sendall(str.encode(""+l+"", 'iso-8859-1'))
        l = f.read(1024)
    f.close()

    csock.close()
</code>```

Result on browser

Body:
I'm trying to learn socket programming with python, and I've created a simple webserver, and I can connect to it in my browswer. I've opened an html file and send it, but it's not displaying in the browswer.

My simple webserver

import socket
import os

# Standard socket stuff:
host = ''
port = 8080
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((host, port))
sock.listen(5)

# Loop forever, listening for requests:
while True:
    csock, caddr = sock.accept()
    print("Connection from: " + str(caddr))
    req = csock.recv(1024)  # get the request, 1kB max
    print(req)
    # Look in the first line of the request for a move command
    # A move command should be e.g. 'http://server/move?a=90'
    filename = 'static/index.html'
    f = open(filename, 'r')
    l = f.read(1024)
    while (l):
        csock.sendall(str.encode("""HTTP/1.0 200 OK\n""",'iso-8859-1'))
        csock.sendall(str.encode('Content-Type: text/html\n', 'iso-8859-1'))
        csock.send(str.encode('\n'))
        csock.sendall(str.encode(""+l+"", 'iso-8859-1'))
        print('Sent ', repr(l))
        l = f.read(1024)
    f.close()

    csock.close()

index.html

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Title</title>

This is the body

I'm very new at this, so I'm probably just missing a very minute details, but I'd love some help on getting the html file to correctly display in the browser.

Body:
I've tried your script works fine by the way.
Maybe you need to check the filename value.

note: little change to make sure all strings on html file sent.

import socket
import os

# Standard socket stuff:
host = ''
port = 8080
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((host, port))
sock.listen(5)

# Loop forever, listening for requests:
while True:
    csock, caddr = sock.accept()
    print("Connection from: " + str(caddr))
    req = csock.recv(1024)  # get the request, 1kB max
    print(req)
    # Look in the first line of the request for a move command
    # A move command should be e.g. 'http://server/move?a=90'
    filename = 'static/index.html'
    f = open(filename, 'r')

    csock.sendall(str.encode("HTTP/1.0 200 OK\n",'iso-8859-1'))
    csock.sendall(str.encode('Content-Type: text/html\n', 'iso-8859-1'))
    csock.send(str.encode('\r\n'))
    # send data per line
    for l in f.readlines():
        print('Sent ', repr(l))
        csock.sendall(str.encode(""+l+"", 'iso-8859-1'))
        l = f.read(1024)
    f.close()

    csock.close()

Result on browser


问:
Aggregation Query adjusting dates for timezone
I want to run this mongodb query using java code.

Query :

```<code>db.log.aggregate([
    { $match : {
        "ts" : {
            $gte: ISODate("2015-07-31T18:30:00.000Z"),
            $lt: ISODate("2015-08-01T18:30:00.000Z")
        },
        "dup": {$exists:false}
    }},
    { $project : {
        'lts': {
            '$add': ['$ts',5.5*3600*1000]
        }
    }},
    { $group : {
        _id : {
            day: { $dayOfMonth: "$lts" },
            month: { $month: "$lts" },
            year: { $year: "$lts" }
        },
        count: { $sum: 1 }
    }}
])
</code>```

i have tried with this code but its not worked

```<code>                                                                                DBObject query = QueryBuilder.start().put("ts").greaterThanEquals(startdate).lessThanEquals(enddate).and("dup").exists(false).get();
     DBObject match = new BasicDBObject("$match", query);
     DBObject project=new BasicDBObject("$project", new BasicDBObject("ts",new BasicDBObject("$add",5.5*3600*1000)));
    DBObject group = new BasicDBObject("$group", new BasicDBObject("_id",new BasicDBObject("day", new BasicDBObject("$dayOfMonth", "$ts"))
    ).append("count", new Document("$sum", 1)));

    AggregationOutput output = collection.aggregate(match,group);

    for (DBObject result : output.results()) {
         System.out.println(result);
         }
</code>```

答:
change field ts to east 8 timezone:</p>

```<code>    BasicDBObject addEightHour = new BasicDBObject("$add", Arrays.asList( "$ts", 8*1000*60*60 ));
    final BasicDBObject day = new BasicDBObject("$dateToString", new BasicDBObject("format", "\"%Y%m%d\"").append("date", addEightHour));

    DBObject groupFields = new BasicDBObject("_id", new BasicDBObject(
            "value", day));
    DBObject group = new BasicDBObject("$group", groupFields);
</code>```

Body:
I want to run this mongodb query using java code.

Query :

db.log.aggregate([
    { $match : {
        "ts" : {
            $gte: ISODate("2015-07-31T18:30:00.000Z"),
            $lt: ISODate("2015-08-01T18:30:00.000Z")
        },
        "dup": {$exists:false}
    }},
    { $project : {
        'lts': {
            '$add': ['$ts',5.5*3600*1000]
        }
    }},
    { $group : {
        _id : {
            day: { $dayOfMonth: "$lts" },
            month: { $month: "$lts" },
            year: { $year: "$lts" }
        },
        count: { $sum: 1 }
    }}
])

i have tried with this code but its not worked

                                                                                DBObject query = QueryBuilder.start().put("ts").greaterThanEquals(startdate).lessThanEquals(enddate).and("dup").exists(false).get();
     DBObject match = new BasicDBObject("$match", query);
     DBObject project=new BasicDBObject("$project", new BasicDBObject("ts",new BasicDBObject("$add",5.5*3600*1000)));
    DBObject group = new BasicDBObject("$group", new BasicDBObject("_id",new BasicDBObject("day", new BasicDBObject("$dayOfMonth", "$ts"))
    ).append("count", new Document("$sum", 1)));

    AggregationOutput output = collection.aggregate(match,group);

    for (DBObject result : output.results()) {
         System.out.println(result);
         }

Body:
change field ts to east 8 timezone:

    BasicDBObject addEightHour = new BasicDBObject("$add", Arrays.asList( "$ts", 8*1000*60*60 ));
    final BasicDBObject day = new BasicDBObject("$dateToString", new BasicDBObject("format", "\"%Y%m%d\"").append("date", addEightHour));

    DBObject groupFields = new BasicDBObject("_id", new BasicDBObject(
            "value", day));
    DBObject group = new BasicDBObject("$group", groupFields);


问:
How to iterate through multiple arrays for every position in the first array iterate the second array?
```<code>#include "stdafx.h"
#include <stdio.h>
#include "iostream"

char s[100];
char s1[100];

int i = 0;
int i1 = 0;
int i2 = 0;

void populate();
void squeeze();

int main()
{
  printf("Write something, hit enter and than write something again. Hit
  enter to see result\n");

  populate();
  squeeze();

  system("pause");

  return 0;
}

void populate()     // insert chars in two arrays
{
  int c;

  while ((c = getchar()) != '\n')
  {
      s[i] = c;
      i++;
  }

  while ((c = getchar()) != '\n')
  {
      s1[i1] = c;
      i1++;
  }
}

void squeeze()      // iterate the arrays to find if there are same chars
{
  char s2[1000];
  i = 0;
  i1 = 0;

  for (int r = 0; r <= s[i - 1]; r++)
  {
      for (int j = 0; j <= s1[i1 - 1]; j++)
      {
        if (s[r] == s1[j])
        {
            s2[i2] = s[r];
            i2++;
        }
      }
  }
  for (int m = 0; m <= s2[i2 - 1]; m++)    //print every element in s2[];
  {
      printf("%c", s2[m]);
  }
}
</code>```

I want to iterate through the second array s1 for every element in the first array s and put the duplicates in the third array s2.

For all I found on the net by far is how to iterate through two or more arrays in the same position arr1[i] = arr2[i], arr1[i1] = arr2[i1] and so on. This is my code, but from unknown reasons for me it does not work.

答:
```<code>  i = 0;
  i1 = 0;
</code>```

You are losing the length of the arrays s and s1. And then you access array index out of bound invoking Undefined behavior.(in squeeze).

The correct way to do it would be

```<code>void squeeze(void)      // iterate the arrays to find if there are same chars
{
  char s2[1000];

  for (size_t r = 0; r < i; r++)
  {
      for (size_t j = 0; j < i1; j++)
      {
        if (s[r] == s1[j])
        {
            s2[i2] = s[r];
            i2++;
        }
      }
  }
  for (size_t m = 0; m < i2; m++)    //print every element in s2[];
  {
      printf("%c", s2[m]);
  }
}
</code>```

Few points to note:

Use global variables are not needed here. You yourself made the mistake of modifying a global variable. With time in large codes using too many global variables makes it less maintainable and readable.

Know how to pass parameter in a function. And also look into functions like fgets which serves the purpose of input in your case.

Check these two resources. These will help you a lot

how-to-debug-small-programs

Definitive C books

Body:
#include "stdafx.h"
#include <stdio.h>
#include "iostream"

char s[100];
char s1[100];

int i = 0;
int i1 = 0;
int i2 = 0;

void populate();
void squeeze();

int main()
{
  printf("Write something, hit enter and than write something again. Hit
  enter to see result\n");

  populate();
  squeeze();

  system("pause");

  return 0;
}

void populate()     // insert chars in two arrays
{
  int c;

  while ((c = getchar()) != '\n')
  {
      s[i] = c;
      i++;
  }

  while ((c = getchar()) != '\n')
  {
      s1[i1] = c;
      i1++;
  }
}

void squeeze()      // iterate the arrays to find if there are same chars
{
  char s2[1000];
  i = 0;
  i1 = 0;

  for (int r = 0; r <= s[i - 1]; r++)
  {
      for (int j = 0; j <= s1[i1 - 1]; j++)
      {
        if (s[r] == s1[j])
        {
            s2[i2] = s[r];
            i2++;
        }
      }
  }
  for (int m = 0; m <= s2[i2 - 1]; m++)    //print every element in s2[];
  {
      printf("%c", s2[m]);
  }
}

I want to iterate through the second array s1 for every element in the first array s and put the duplicates in the third array s2.

For all I found on the net by far is how to iterate through two or more arrays in the same position arr1[i] = arr2[i], arr1[i1] = arr2[i1] and so on. This is my code, but from unknown reasons for me it does not work.

Body:
  i = 0;
  i1 = 0;

You are losing the length of the arrays s and s1. And then you access array index out of bound invoking Undefined behavior.(in squeeze).

The correct way to do it would be

void squeeze(void)      // iterate the arrays to find if there are same chars
{
  char s2[1000];

  for (size_t r = 0; r < i; r++)
  {
      for (size_t j = 0; j < i1; j++)
      {
        if (s[r] == s1[j])
        {
            s2[i2] = s[r];
            i2++;
        }
      }
  }
  for (size_t m = 0; m < i2; m++)    //print every element in s2[];
  {
      printf("%c", s2[m]);
  }
}

Few points to note:

Use global variables are not needed here. You yourself made the mistake of modifying a global variable. With time in large codes using too many global variables makes it less maintainable and readable.

Know how to pass parameter in a function. And also look into functions like fgets which serves the purpose of input in your case.

Check these two resources. These will help you a lot

how-to-debug-small-programs

Definitive C books


答:
Typical runtime libraries provide a feature that makes it easy to initialise data to 0. In general terms, this is stored in a specific section in the executable, organised by the compiler and linker. At program startup, the runtime startup code uses something like memset() to clear out all the initialised data to 0. This means that the zero bytes don't have to be stored inside the executable itself.

The converse is that if you initialise data to something other than zero, then the bytes for that data must be stored in the executable itself, since the automatic initialiser only initialises to zero.

Therefore, if you were to declare a big array of char (say a megabyte?) and initialise it with, say, {0}, then there would not be bytes stored in the executable for that array. On the other hand, if you were to initialise it with {1} under your scheme, a megabyte of 1 bytes would have to be stored in the executable itself. By changing one character in the initialiser list, the size of the executable increases by a megabyte.

I believe such a scheme would violate the principle of least surprise.

Title: Why the difference between int a[5] = {0} and int a[5]={1} (Missing Feature)

Body:
When we initialize an array like this int a[5] = {0}, the compiler makes all 5 elements 0. That is really good, compact-initialization and useful feature.

But I wonder why the compiler doesn't initialize int a[5]={1} similarly? Why does it not make all 5 elements 1? Why the Standard doesn't mandate it? Would it not been an awesome feature? Isn't it missing?

Also, if the number of elements in the initializer is less than the size of the array, then the compile could initialize the remaining elements with the last element in the initializer. Means, int a[5]={1,2,3} is equivalent to int a[5]={1,2,3,3,3}. And similarly, int a[10]={1,2,3,0} is equivalent to int a[10]={1,2,3,0,0,0,0,0,0,0};.

Would it all not be an awesome feature if the Standard mandates it? Or is there any good reasons for this missing feature?

And there is something called designated initializer in C99, which is used like:

Designated initializers can be
  combined with regular initializers, as
  in the following example:

int a[10] = {2, 4, [8]=9, 10}

In this
  example, a[0] is initialized to 2,
  a1 is initialized to 4, a[2] to a[7]
  are initialized to 0, and a[9] is
  initialized to 10.

Quite interesting. But even this feature is not in C++.