Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. It's just a matter of organising your ajax response. Send it back as an array containing two arrays, one for table A and one for table B
  2. The technique you want is AJAX +-----------------+ +-----------------+ | browser page | | Server | |-----------------| AJAX request |-----------------| | Send | -----------------------------> | Query DB | | | with search data | | | | | | | | | | | | | | Process | <---------------------------- | return response | | response | | | | | | | | | | | | | | | +-----------------+ +-----------------+
  3. The best place to set them is in your php.ini file. If you have startup errors (such as syntax errors) you need display_startup_errors ON, but you can't set that from within a script. This is the relevant section of my development php.ini file.
  4. A alternative to setting them as selected when you add them to ListB is to use a javascript function to select them all just prior to submitting the form... <?php if (isset($_GET['selected_counties'])) { foreach ($_GET['selected_counties'] as $cname) { echo "$cname<br>"; } } echo '<hr>'; ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>County Selection</title> <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script type='text/javascript'> function doSubmit() { $.each( $("#selected_counties").children(), function(k,v) { $(v).attr("selected","selected") // set items as selected }) return true; // submit the form } </script> </head> <body> <form onsubmit = "return doSubmit()"> <select name='selected_counties[]' id='selected_counties' multiple size='5'> <option>Adams</option> <option>Barron</option> <option>Buffalo</option> <option>Clark</option> <option>Dodge</option> </select> <button type='submit'>Submit</button> </form> </body> </html>
  5. Good a reason as any.
  6. WHy have two lists of counties. Can't the user just select multiple counties (ctrl-click) in the first list? For example <?php if (isset($_GET['counties'])) { foreach ($_GET['counties'] as $cname) { echo "$cname<br>"; } } echo '<hr>'; ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Bookstore</title> </head> <body> <form> <select name='counties[]' multiple size='5'> <option>Adams</option> <option>Barron</option> <option>Buffalo</option> <option>Clark</option> <option>Dodge</option> </select> <button type='submit'>Submit</button> </form> </body> </html>
  7. Doh! Forget that - I just answered my own question as I posted - if they aren't selected they don't get sent. When you write the options to ListB, set their selected attributes <option selected>Adams</option>
  8. Why does that matter? As soon as the user clicks "Submit", the searchTest.php page should appear with the search results (at least I assume that happens next).
  9. If I understand what you're saying Show available counties in ListA Drag some counties from ListA to ListB When counties are selected in ListB, add them to ListC You stated you are doing a database search. Do you then want to submit ListC to search for items in those counties?
  10. Use the reference manual at php.net. It's always up-to-date and I believe there is a US version available.
  11. The first query is returning neither a count of records nor an array - it returns a result object $q = "SELECT COUNT(*) FROM $db_table"; $res = $pdo->query($q); $num = $res->fetchColumn(); However, that code is totally superfluous - you don't need the count just to get a random record. $q = "SELECT quote,author FROM quotes ORDER BY RAND() LIMIT 1";
  12. $num will not contain the record count. Why is that $num being used in the call to RAND() function?
  13. +1
  14. You engineered it. When you started citing me in your posts as being responsible for the original code you gave me two undesirable options... I could carry on ignoring the posts, but then I would look bad in everyone's eyes for being the one who knew the code but apparently leaving you in the lurch, or I could submit to your coercion to make me carry on helping you with the project, albeit via the forum. When on the horns of a dilemma one looks for a third option. And should I be grateful for your selling my code without my permission and generously offering me 50%?
  15. Save jarvis's latest code in "/htdocs/book.php" then try this in your browser's address bar http://localhost/book.php?title=War+and+Peace&author=Tolstoy and see if that works.
  16. It displays an interactive map of his association's marina, showing all the berths and the boats in each berth. Clicking on a boat displays details of the boat and (if the user is logged in as a member) it displays contact details of the boat owner. It also allows you move boats from one berth to another, or from the waiting lists at the bottom to an empty berth. All changes update the database. Having made a change the map is redrawn. As you can see from the image below, it worked when it left the shop (login too, so it can display the owner details). I wrote this, and a few other pages, for Leon as a hobby project during the lockdown. If you examine the lower right-hand edge of the image you will see my name. When he put it on his site that name had been removed and he added footer proclaiming "Design and Development by...<his site>". If you look at the posted code (line 300 - about halfway down - my name is there but now commented out). I told him that as he wanted to claim all the credit for the design and developent then he should actually do it all. I then ceased communication. Given that history, it seems strange he should be publically crediting me now he has screwed with the code and it has all gone FUBAR. Whether he intends it as blame or just to try and embarrass me into helping out, I'm not sure. But it does give me no choice but to explain publically why I am not rushing forward to help with his problems.
  17. I have no idea what I am looking in that example. Abstract examples seldom work. Am I looking at one record from each csv, or eight records from the first csv and six from the second Perhaps you could post the first 10 records from each csv so I can see what the data looks like.
  18. What have you tried?
  19. You could save the output as an image file and import that into the PDF file. FPDF supports png, jpeg, gif TCPDF supports the above plus SVG images (and you can also embed SVG script into the PDF)
  20. The dbfiddle link that was in your post when I tried it had two sets of "..." in the middle of the reference. The one that's there now is not the original.
  21. I'm sorry you find that request difficult to comprehend. If I can see the data I might be able to work out why you are getiing the problem with that query. Without the data I will have to create the tables myself, but as I don't yet know the cause, I cant add data that is going to cause the problem. But as you are unwilling to help me to you with your problem, I'll bow out now. Good luck.
  22. That dbfidlle link is as much use as a chocolate teapot.
  23. Can you you provide some test data for those two tables that exhibits this problem?
  24. The data looks OK. It could do with some separation between the blocks of student data to make it easier to read. Perhaps... foreach($results_by_date as $name => $work) { foreach($work as $kdate => $date) { if($kdate == 'date'){ echo str_repeat('-', 20)."\n" ; echo $date. "\n\n"; }else{ foreach($date as $kdata => $date_data){ foreach($date_data as $kdatakey => $data){ echo "&nbsp;" . $data. "\n"; } echo "&nbsp;\n" ; } } } } FYI, this is my version for cli output // JSON from previous script saved in file $results = json_decode(file_get_contents('c:/inetpub/wwwroot/test/doc1355/rohan.json'), 1); $pad = str_repeat(' ', 8); $divs = $pad . str_repeat('-', 12) . PHP_EOL; $divd = str_repeat('-', 20) . PHP_EOL; echo '<pre>'; // test only - not required in CLI mode foreach ($results as $day) { echo $day['date'] . PHP_EOL . PHP_EOL; foreach ($day['students'] as $k => $sdata) { if ($k) echo $divs; foreach ($sdata as $val) { echo $pad . $val . PHP_EOL; } } echo $divd; }
  25. It fails if the output values from the the new test script don't match the original table's values. For example, the output from my test script, built from the JSON data, looks like this (which can be easily compared with the original) ... You aren't compelled to use my method. Feel free to think up your own.
×
×
  • 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.