Jump to content

Barand

Moderators
  • Posts

    24,324
  • Joined

  • Last visited

  • Days Won

    794

Barand last won the day on April 16

Barand had the most liked content!

About Barand

Profile Information

Recent Profile Visitors

95,931 profile views

Barand's Achievements

Prolific Member

Prolific Member (5/5)

2.1k

Reputation

467

Community Answers

  1. From the manual: I'd recommend using PDO instead of mysqli.
  2. If you miss a semi-colon then no code runs because of the syntax error. It doesn't get as far as any errors that may occur. (set "diplay_startup_errors" ON in your php.ini file to be informed of any syntax errors. Post your error messages - it helps us.
  3. Doesn't clearfix make a mess of your screen?
  4. The boards are quiet at the moment so I thought you might glad of something to exercise your little grey cells. When I was 17 I borrowed a maths book from the local library and in it was this simple question (posed by the speaker at a Royal Mathematical Society dinner)... What is the smallest integer that when the first digit is moved to the end, the new number is exactly one and a half times the original?
  5. They'll be back when they realize that the AI generated code doesn't* do exacty what they wanted. *edit - I seemed to have missed out a critical word🙄
  6. Maybe. I have no way of knowing what you intend to do with the index and the function parameters. Two things to bear in mind ID values must be unique - you cant have several inputs all with the id="comment_text2" When you define an event listener on page load, it is only attached to elements that exist when the page has loaded and not to elements you add dynamically.
  7. 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.
  8. And how is the user expected to interact with it? Can you display a form with a select and an input text user enters comment user clicks "Save" form is posted and comment saved page reloads Rinse and repeat as many times as required?
  9. It would help if you explained what you are trying to achieve. Code that doesn't work only shows us what you don't want to do. What do want to do (30?) times in a loop. For example... Are you meaning there may be 30 emojis, or there will be 30 select/input text pairs?
  10. 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.
  11. If it is going into a database then you should be using prepared queries which will guard against SQL injection. Mozilla Developer Network (MDN)
  12. Then use the actual name of your PDO connection object instead of $pdo. My apologies for not being psychic.
  13. Loop through the returned results of your function and output the options <?php foreach (getCompanyName($pdo) as $row) { echo "<option value='{$row['id']}'>{$row['name']}</option>" ; } ?>
  14. Simple method using a couple of classes (See https://dev.to/alexandrefreire/bootstrap-4-hiding-elements-in-responsive-layout-3g25) Code <html> <head> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"> </head> <body> <div > <img src='no_photo.jpg' border='0' width='102' height='104' alt='no_photo.jpg (2,382 bytes)' class='d-block d-md-none'> <img src='parrots.JPG' border='0' width='397' height='191' alt='parrots.JPG (22,358 bytes)' class='d-none d-md-block'> </div> </body> </html> Output width = 420 Output width = 800
  15. Whenever I want to print, I write to a PDF file which then downloads to the browser for printing.
×
×
  • 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.