Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Barand last won the day on December 4

Barand had the most liked content!

About Barand

Profile Information

Recent Profile Visitors

102,486 profile views

Barand's Achievements

Prolific Member

Prolific Member (5/5)

2.1k

Reputation

494

Community Answers

  1. mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); Add the above line just before the line that creates your db connection. Make sure error reporting is on.
  2. Post the full version of the code that isn't working.
  3. My database connection code is not present in the code I posted.. Hava you added your pdo connection code at the top of the script?
  4. Is "index.php" defined as the default document name?
  5. Thanks for letting us know.
  6. Here's an example. As you enter more letters of the name it narrows down the resulting list. (first and last names are searched) <?php # # HANDLE AJAX REQUESTS # if (isset($_GET['ajax'])) { if ($_GET['ajax'] == 'names') { $res = $pdo->prepare("SELECT id , concat(fname, ' ', lname) as name FROM person WHERE fname LIKE ? OR lname LIKE ? ORDER BY fname, lname "); $res->execute([ $_GET['search'], $_GET['search'] ]); $results = $res->fetchAll(); exit(json_encode($results)); } } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Example</title> <meta charset="utf-8"> <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> <style type='text/css'> </style> <script type='text/javascript'> $(function() { $("#search").on("input",function() { let srch = $(this).val() + "%" $.get( "", {"ajax":"names", "search":srch}, function(resp) { $("#person").html("") $.each(resp, function(k,v) { let opt = $("<option>", {"value":v.id, "text":v.name}); $("#person").append(opt); }) }, "JSON" ) }) }) </script> </head> <body> <form> Enter first part of name: <input type='text' id='search' > <br><br> <select name='person_id' id='person' size='20'> <!-- names returned from search go here --> </select> </form>
  7. Why not have a dropdown for the persons. Then it's select person select job submit form (now has person_id and job_id from the selects)
  8. Why waste your time writing JS code to replicate what the browser code already does (and compiled browser code will do the job far more efficiently than JS code)
  9. 1) Do you have php's error reporting ON and error level set to E_ALL? 2) Have you turned mysql's error reporting on with mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); immediately before your call to $con = mysqli_connect( ... )
  10. But only if you can guarantee that the oldest records are always added first. If relative age is important why would you not store the date added? Having a date also has the advantage that you can have the option to DELETE FROM tablename WHERE datecol < CURDATE() - INTERVAL ? DAY so you can delete all those over N days old
  11. select <whatever> from <tablename> order by date_created limit 20
  12. Is this any use to you? <!DOCTYPE html> <html lang="en"> <head> <title>Wordle Assist</title> <meta charset="utf-8"> <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> <style type='text/css'> @media print { .printme { visibility: visible; display: block; } .noprint { visibility: hidden; } } #print { font-family: "times new roman", serif; font-size: 20pt; } #address { margin: 50px; line-height: 40px; } </style> <script type='text/javascript'> $(function() { if ($("#address").text() != '') { print() } }) </script> </head> <body> <div id='address' class='printme'> <?= nl2br($_GET['addy'] ?? '') ?> </div> <header class='noprint'> <h1>Address Labels</h1> </header> <form class='noprint'> Address:<br><br> <textarea cols='60' rows='5' name='addy'></textarea> <br><br> <button id=btnPrint'>Print</button> </form> </body> </html>
  13. Hvae you looked at the page's html source code?
  14. No hablo Laravelese. Sorry, I've never used it.
×
×
  • 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.