Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 04/16/2024 in all areas

  1. Alright, this one took me a while to remember how to do. It's part of a class of problems of manipulating one number's digits to come up with another number, and the work to solve it tends to have a common pattern.
    1 point
  2. Using filter_input_array with FILTER_SANITIZE_FULL_SPECIAL_CHARS for both $_GET and $_POST can provide an additional layer of security by sanitizing input data. However, keep in mind that it may cause unintended behavior if applied indiscriminately to all input. It's generally considered safe, especially when combined with htmlspecialchars, but ensure it doesn't interfere with any specific requirements or data types in your application. Best Regard Danish Hafeez | QA Assistant ICTInnovations
    1 point
  3. I like to use data attribute on these occasions. NOTE: use a class name for the selects and another for the inputs. Don't use ids. Maintain a count of how many comments the user adds and increment each time they add a new one. When creating a new select and input, give them both a data-id attribute with the value of the count. When emoji selected, get the value of the select's data-id. Look for the input with the same data_id and insert the emoji.
    1 point
  4. I agree with mac_gyver except for the use of OR in the WHERE clause. Consider this product table... +------------+-------------------------+ | product_id | description | +------------+-------------------------+ | 1 | Black mamba | | 2 | Fireball XL5 | | 3 | Single coat black paint | | 4 | Coat of many colours | | 5 | Black coat XL | | 6 | Not of interest | +------------+-------------------------+ Code... $search = 'coat black xl'; $params = array_map(fn($v)=>"%$v%" , explode(' ', $search)); $q1 = "SELECT description FROM product -- search query using OR WHERE description LIKE ? OR description LIKE ? OR description LIKE ? "; $q2 = "SELECT description FROM product -- search query using AND WHERE description LIKE ? AND description LIKE ? AND description LIKE ? "; Results... Results using OR +-------------------------+ | description | +-------------------------+ | Black mamba | | Fireball XL5 | | Single coat black paint | | Coat of many colours | | Black coat XL | +-------------------------+ Results using AND +---------------+ | description | +---------------+ | Black coat XL | +---------------+ A couple of other options are open to you FULLTEXT Add fulltext index on description and $q3 = "SELECT description , MATCH(description) AGAINST('coat black xl') as relevance FROM product WHERE MATCH(description) AGAINST('coat black xl') ORDER BY relevance DESC " ; +-------------------------+-------------------+ | description | relevance | +-------------------------+-------------------+ | Black coat XL | 0.18123811483383 | | Single coat black paint | 0.18123811483383 | | Coat of many colours | 0.090619057416916 | | Black mamba | 0.090619057416916 | +-------------------------+-------------------+ NOTE: with fulltext, words of 3 or less characters (eg "XL") are ignored. Use separate columns for category, colour and size and search on those.
    1 point
  5. Then use the actual name of your PDO connection object instead of $pdo. My apologies for not being psychic.
    0 points
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.