Jump to content

funbinod

Members
  • Content Count

    490
  • Joined

  • Last visited

Community Reputation

3 Neutral

About funbinod

  • Rank
    Member
  • Birthday 05/12/1983

Contact Methods

  • Yahoo
    funbinod
  • Skype
    binod.anuj

Profile Information

  • Location
    Nepal

Previous Fields

  • Languages
    HTML, PHP, JAVASCRIPT

Recent Profile Visitors

5,630 profile views
  1. funbinod

    problem with parent-child rows selection

    this hint solved my problem. i cheated the code like below. .......... AND projtype IN (SELECT id FROM projcat WHERE under=1 UNION SELECT id FROM projcat WHERE id=1 UNION SELECT id FROM projcat WHERE under IN (SELECT id FROM projcat WHERE under=1)) thank u very very much...
  2. funbinod

    problem with parent-child rows selection

    thank you for the reply. but it banged my head. this is beyond my practice and is very tough to understand. can't it be done with a simple modification to my code???? like........ .......... AND projtype IN (1, SELECT id FROM projcat WHERE under=1 UNION SELECT id FROM projcat WHERE under IN (SELECT id FROM projcat WHERE under=1)) thank u again.
  3. hello all! i am struggling with a problem in mysql. i want to select all rows from a table with an id and its child ids. i tried the following ............... AND projtype IN (SELECT id FROM projcat WHERE under=1 UNION SELECT id FROM projcat WHERE under IN (SELECT id FROM projcat WHERE under=1)) it works. But this selects rows that matched the child ids only. i want to select all the rows which use the parent id also (i.e. '1' on the given example). please help me with some hints. thanks in advance....
  4. hi all! after long time i'm back here with a problem. i want to select all data attributes from a div with its name and value using jquery each function use that elsewhere. here is the html for the div. <div class='EW' data-rowid='1' data-unit='' data-workdesc='description' data-vby='2' data-distanceTot='50' data-AVcutTot='500' data-VcutTot='25000'></div> and i tested the following to get my result. var datas = $(".EW").attributes; $.each(datas, function(i,item) { $("#msg").text(item.name + ":" + item.value); }) but i could not get any result. can u please guide me what is wrong? or suggest me any other best method to achieve this. thank you in advance.
  5. funbinod

    remove elements not in for loop range

    thank u. this suggestion solved the problem var remove = []; for (i=enclass; i<=12; i+=enclass) { remove.push(i); } if ($.inArray(parseInt($(this).parent("td").attr("class")), remove) == -1) { $(this).remove(); }
  6. hello all! i was trying to do a for loop to remove all elements that does not meet the for loop. following is the code i tried. $("#feetable input").each(function(e) { var thisvalue = $(this).val(); var enclass = 3; var i; for (i=enclass; i<=12; i+=enclass) { if ($(this).parent("td").attr("class") == i && $(this).val() == thisvalue) { $(this).remove(); } } }) and here is the html <td class='1'><input type='checkbox' /></td> <td class='2'><input type='checkbox' /></td> <td class='3'><input type='checkbox' /></td> <td class='4'><input type='checkbox' /></td> <td class='5'><input type='checkbox' /></td> <td class='6'><input type='checkbox' /></td> <td class='7'><input type='checkbox' /></td> <td class='8'><input type='checkbox' /></td> <td class='9'><input type='checkbox' /></td> <td class='10'><input type='checkbox' /></td> <td class='11'><input type='checkbox' /></td> <td class='12'><input type='checkbox' /></td> this removes the exact elemetns that the for loop finds (i.e. inputs under <td>s with class 3, 6, 9, 12). but my aim is to keep those inputs and remove others. and when i try to reverse the code as below it removes all the inputs. if ($(this).parent("td").attr("class") != i && $(this).val() == thisvalue) { $(this).remove(); } please guide me. thanks in advance.
  7. funbinod

    MYSQLI REPLACE() function while inserting multiple rows

    wow! this solved the problem. i checked for all the tables and found some columns be empty that led to this problem. i corrected them and found that the above code is working properly. thank u for the idea.
  8. funbinod

    MYSQLI REPLACE() function while inserting multiple rows

    thank u for the reply. and sorry for the undefined table screenshots. here i'm again posting the screenshot with some markings. my purpose of this practice is to change the underlined part of the data before copying and the calculation (math) is for that purpose. i'm copying the bordered 4 rows and the math should be applied for all the rows. but it inserted all the rows but only one row with data and rest NULL. and one more thing. i tried to shorten the code and found some interesting results. the following code inserted all the rows with data INSERT INTO projectra (projid, nermid, name, code, per, unitper, description, materials, manerials, macerials) SELECT '$projid', fullid, name, code, per, unitper, description, REPLACE (materials, SUBSTRING_INDEX(materials, ';', -1), ( (SELECT (lurate) FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) ) ), REPLACE (manerials, SUBSTRING_INDEX(manerials, ';', -1), '0'), REPLACE (macerials, SUBSTRING_INDEX(macerials, ';', -1), '0') FROM nerms WHERE fullid='$nid'"); and the following code inserted 2 rows with data and 2 rows NULL INSERT INTO projectra (projid, nermid, name, code, per, unitper, description, materials, manerials, macerials) SELECT '$projid', fullid, name, code, per, unitper, description, REPLACE (materials, SUBSTRING_INDEX(materials, ';', -1), ( (SELECT (lurate) FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) + ( (SELECT uweight FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) * (SELECT rate FROM transport WHERE name=(CONCAT((SELECT ctype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)), '-BLACK TOPPED')) AND cid='$cid' AND active='Y') * (SELECT SUBSTRING_INDEX((SELECT IF ((SELECT itype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1))='L', Ldistance, Fdistance) FROM projects WHERE fullid='$projid'), ';', 1)) ) ) ), REPLACE (manerials, SUBSTRING_INDEX(manerials, ';', -1), '0'), REPLACE (macerials, SUBSTRING_INDEX(macerials, ';', -1), '0') FROM nerms WHERE fullid='$nid'"); the second part of the addition could be any one among the three on the main code. thank u again.
  9. funbinod

    MYSQLI REPLACE() function while inserting multiple rows

    thank u for the reply. but if my explanation above was unclear i again explain - columns with data also converts to NULL except one row. you can check those two screenshots.
  10. i was trying to insert rows from one table to another and edit values before inserting. for that i did the following INSERT INTO projectra (projid, nermid, name, code, per, unitper, description, materials, manerials, macerials) SELECT '$projid', fullid, name, code, per, unitper, description, REPLACE (materials, SUBSTRING_INDEX(materials, ';', -1), ( (SELECT (lurate) FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) + ( (SELECT uweight FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) * (SELECT rate FROM transport WHERE name=(CONCAT((SELECT ctype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)), '-BLACK TOPPED')) AND cid='$cid' AND active='Y') * (SELECT SUBSTRING_INDEX((SELECT IF ((SELECT itype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1))='L', Ldistance, Fdistance) FROM projects WHERE fullid='$projid'), ';', 1)) ) + ( (SELECT uweight FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) * (SELECT rate FROM transport WHERE name=(CONCAT((SELECT ctype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)), '-GRAVELL')) AND cid='$cid' AND active='Y') * (SELECT SUBSTRING_INDEX(SUBSTRING_INDEX((SELECT IF ((SELECT itype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1))='L', Ldistance, Fdistance) FROM projects WHERE fullid='$projid'), ';', 2), ';', -1)) ) + ( (SELECT uweight FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) * (SELECT rate FROM transport WHERE name=(CONCAT((SELECT ctype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)), '-EARTHEN')) AND cid='$cid' AND active='Y') * (SELECT SUBSTRING_INDEX((SELECT IF ((SELECT itype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1))='L', Ldistance, Fdistance) FROM projects WHERE fullid='$projid'), ';', -1)) ) ) ), REPLACE (manerials, SUBSTRING_INDEX(manerials, ';', -1), '0'), REPLACE (macerials, SUBSTRING_INDEX(macerials, ';', -1), '0') FROM nerms WHERE fullid='$nid'"); this works very good - calculates and replaces the exact point as expected. but the problem is it calculates only one random row and lefts other to be NULL. for example, if there are 4 rows that meet the condition, all the 4 rows are copied but only one row contain the expected data and others are left to be NULL. i've submitted 2 screenshots of phpmyadmin showing 2 tables - first one is from which i am coping data (there you can see data on cells) and another is of next table after the copying data (there you can see NULL on cells). thanks in advance...
  11. funbinod

    insert csv into mysql problem

    PHP error is enabled. and there is nothing added on error log of my cpanel. the only thing happens when i post the csv file is - "Aw, Snap" page. its so much confusing. it works very fine when i use LOAD DATA method.
  12. funbinod

    insert csv into mysql problem

    i've posted the screenshot. it just displays "Aq, Snap!" DEV TOOLS also disconnects. and yes! the file upload is done through jQuery ajax. when i check manually, the file uploads but the mysql inserting part is not executed. and i found some mistakes on my code. i corrected it as following. but it still is not performing the action. $q = $mysqli->prepare("INSERT INTO projects (name, ctrtype, budhead, code, wardno, govallo, startdate, enddate, fy, cid, uid) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); if (!$q) { echo "<div id='success'>NO</div>"; echo "<div id='msg'>Error: $mysqli->error</div>"; } else { $q->bind_param("siisidssiii", $prjname, $ctrtype, $data[2], $data[3], $data[4], $data[5], $data[6], $data[7], $ay, $cid, $uid); if (!$q->execute()) { echo "<div id='success'>NO</div>"; echo "<div id='msg'>Error: $q->error</div>"; } else { echo "<div id='success'>YES</div>"; echo "<div id='msg'>SUCCESSFULLY INSERTED DATA IN FILE!</div>"; $_SESSION["msg"] = "SUCCESSFULLY INSERTED DATA IN FILE!"; } }
  13. funbinod

    insert csv into mysql problem

    because i want to filter data supplied in the csv file.
  14. funbinod

    insert csv into mysql problem

    hello all! i am trying to upload and insert data on a csv file to mysql. it uploads but could not insert data to mysql. following is the work i've done. $handle = fopen($targetpath, 'r'); $firstline = true; while (($data = fgetcsv($handle, 5000, ',')) !== FALSE) { if (!$firstline) { $continue = true; if ($data[0] == "" && $data[1] == "" && $data[2] == "" && $data[3] == "" && $data[4] == "" && $data[5] == "" && $data[6] == "" && $data[7] == ""){ $continue = false; } if (strlen($data[0]) != strlen(utf8_decode($data[0]))) { $prjname = ($data[0]); } else { $prjname = strtoupper($data[0]); } if ($data[1] == "CONTRACTOR") { $ctrtype = 1; } else if ($data[1] == "USER COMMITTEE") { $ctrtype = 2; } else { $continue = false; } if (!is_numeric($data[2])) { $continue = false; } if ($continue == true) { $q = $mysqli->query("INSERT INTO projects (subdate, name, ctrtype, budhead, code, wardno, govallo, startdate, enddate, fy, cid, uid) VALUES ('$subdate', '$prjname', '$ctrtype', '$data[2]', '$data[3]', '$data[4]', '$data[5]', '$data[6]', '$data[7]', '$ay', '$cid', '$uid')"); if (!$q) { echo "<div id='success'>NO</div>"; echo "<div id='msg'>Error: $mysqli->error</div>"; } else { $q->bind_param("siisidssiii", $subdate, $prjname, $ctrtype, $data[2], $data[3], $data[4], $data[5], $data[6], $data[7], $ay, $cid, $uid); if (!$q->execute()) { echo "<div id='success'>NO</div>"; echo "<div id='msg'>Error: $q->error</div>"; } else { echo "<div id='success'>YES</div>"; echo "<div id='msg'>SUCCESSFULLY INSERTED DATA IN FILE!</div>"; $_SESSION["msg"] = "SUCCESSFULLY INSERTED DATA IN FILE!"; } } } } $firstline = false; } unlink($path); can u please guide where i did mistake??? thank u in advance..
  15. funbinod

    setting page break

    tr:nth-child(4n) {page-break-after: always;} this didnot work as expected
×