Jump to content

niche

Members
  • Content Count

    3,460
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by niche

  1. niche

    Adding a 2d constraint

    This produces the lowest price subset of the query in the OP. Do you see any issues? SELECT *, MIN(price) AS minprice FROM ( SELECT id , nconnectz.item_id , nconnectz.vendor_id , nconnectz.datetime2 , nconnectz.itemandsize , nconnectz.price FROM ( SELECT item_id , vendor_id , MAX(datetime2) AS latest FROM nconnectz WHERE item_id IN (' . $in . ') AND vendor_id IN (' . $in2 . ') GROUP BY item_id , vendor_id ) AS subset INNER JOIN nconnectz ON nconnectz.item_id = subset.item_id AND nconnectz.vendor_id = subset.vendor_id AND nconnectz.datetime2 = subset.latest ) AS subset2 GROUP BY item_id , vendor_id
  2. niche

    Adding a 2d constraint

    My nconnectz table also has a price column. I've figured out how to get the latest datetime: SELECT nconnectz.item_id , nconnectz.vendor_id , nconnectz.datetime2 FROM ( SELECT item_id , vendor_id , MAX(datetime2) AS latest FROM nconnectz WHERE item_id IN (' . $in . ') AND vendor_id IN (' . $in2 . ') GROUP BY item_id , vendor_id ) AS subset INNER JOIN nconnectz ON nconnectz.item_id = subset.item_id AND nconnectz.vendor_id = subset.vendor_id AND nconnectz.datetime2 = subset.latest What should my thinking be to select the latest datetime with the lowest price?
  3. niche

    strpos

    thanks dsonesuk!
  4. niche

    strpos

    $haystack = ",18,19,42,"; $needle = ",18,"; if (strpos($haystack,$needle)) { echo 'TRUE'; } else { echo 'FALSE'; } This returns FALSE. What am I missing?
  5. Turn's out the problem was in my bootstrap. Thanks to ingolme and jsg. It was jsg's post that got me to thinking more broadly and ingolme's last post that zeroed in on the real problem. Thanks again for your patience.
  6. Thanks for the question jsp. Things just got weirder. Yes, I can select 'Coffee / Tea' directly. Seems I can get the same results even after I change 'Coffee / Tea' to ' ' in the table (new issue)! This is a live Godaddy server. I wonder if it has some kind of a virus or malware? everything else works as expected. EDIT: Cleared cache, got same results on chrome, ff, and ipad. hmmm.
  7. Thanks for your patience. I expect 2 rows returned from the my code. I get zero rows back and no errors. I have visually verified that 2 rows exist with the 'coffee / tea' string. I have also verified that error reporting is working.
  8. all error reporting is on. no error message is displayed. EDIT: Just found out that client manually entered coffee / tea. Does that make a difference?
  9. here's my simple example: try { $sql = 'SELECT itemandsize FROM itemandsize WHERE sub_category = :sub_category' ; $stmt = $this->db->prepare($sql); } catch (PDOException $e) { echo $e->getMessage() . '<br>'; } try { $stmt->execute(array(':sub_category' => $var)); } catch (PDOException $e) { echo $e->getMessage() . '<br>'; } $var = 'coffee / tea' I'm certain that the slash is the problem, but don't know why. Do you know why? I thought treating $var in the array auto resolved all formatting issues. Obviously not. $var = 'coffee - tea' works fine EDIT: Is it just that slashes are used for escaping?
  10. My experience of how mysql determines what result goes first varies, that why I use the ORDER BY keyword.
  11. don't understand your question
  12. niche

    BULK UPDATE

    need to do a join https://www.w3schools.com/sql/sql_join.asp
  13. niche

    addoption syntax

    $ was the givaway sorry about that.
  14. try putting px after 0 EDIT: else, restore to the version before the changes
  15. without access to the offending code that's producing the offending code, I think it's a google problem.
  16. niche

    addoption syntax

    $nt1 is an array https://www.w3schools.com/js/js_arrays.asp EDIT: the info between the commas are arguments addOption is a function (jquery i think)
  17. Sure. A javascript function could easily handle that. EDIT: the function could have a https://www.w3schools.com/jsref/jsref_match.asp and a https://www.w3schools.com/jsref/jsref_match.asp
  18. niche

    Drop down menu

    https://www.w3schools.com/html/html_form_elements.asp see "selection"
  19. https://stackoverflow.com/questions/3632075/mysqli-giving-commands-out-of-sync-error-why see first answer EDIT: suggest you use a sub query or simply use two different queries
  20. niche

    Google Custom search

    a few more facts pls
  21. https://stackoverflow.com/questions/27088849/how-to-insert-a-calculated-sum-in-a-table see the 2nd answer
  22. here's how you do an INSERT: https://www.w3schools.com/sql/sql_insert.asp when i was a beginner I'd do two INSERTS. One to INSERT the original data and one to UPDATE (do the calcs) here's how you do an UPDATE: https://www.w3schools.com/sql/sql_update.asp
  23. what does your INSERT look like? EDIT: here's a link that I refer to from time to time that might help: https://stackoverflow.com/questions/11754781/how-to-declare-a-variable-in-mysql still need to see your INSERT EDIT EDIT: why no ID in your table?
  24. niche

    PHP error

    Gotcha on that open { BTW, I've seen editors that have a hot key that auto formats pasted code. is that what you used? if so, which editor do you use? if not, returning manually formatted code is above and beyond. either way, great work. let me know about your editor. thx again dsonesuk
  25. niche

    PHP error

    wouldn't have got that. thx dsonesuk EDIT Does your text editor have a function to test for an open curly bracket?
×
×
  • Create New...