Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 12/05/2019 in Posts

  1. 1 point
    A good source for php/MySQL interaction (using PDO is recommended) is https://phpdelusions.net/pdo_examples This query should get you started SELECT , scheduled_student_service , category , COUNT(*) as total_appointments , SUM(is_no_show) as no_shows , SUM(is_cancelled) as cancellations FROM thetable GROUP BY scheduled_student_service, category If that isn't what you want, repost with more details. In future, please don't post images of data. They are as much use as chocolate teapots if we need to recreate your data to test with when helping.
  2. 1 point
    Make your join a LEFT JOIN and add the job id condition as part of the join. SELECT menu_name, menu_price, menu_item_name, menu_item_category, b.menu_item_id, a.menu_id, d.job_id, d.menu_item_qty FROM ssm_menu a INNER JOIN ssm_menu_connection b ON a.menu_id = b.menu_id INNER JOIN ssm_menu_items c ON b.menu_item_id = c.menu_item_id LEFT JOIN ssm_menu_order d ON c.menu_item_id = d.menu_item_id AND d.job_id=27 WHERE a.menu_id = 1 On a side note, consider re-formatting your queries. Your current style is quite difficult to read, something like what I put above is much easier.
  3. 1 point
    Perhaps something without all those non-breaking spaces <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Lang" content="en"> <title>Example</title> <style type="text/css"> table { width: 80%; margin: 20px auto; font-family: calibri, sans-serif;} caption { border-bottom: 1px solid gray; } th { text-align: left; padding: 8px 2px; color: #999;} td { color: #25b0e9; padding: 8px 4px; } </style> </head> <body> <table> <caption>Channel State</caption> <tr> <th>&nbsp;</th> <th>C1</th> <th>C2</th> <th>C3</th> <th>C4</th> <th>C5</th> <th>C6</th> <th>C7</th> <th>C8</th> </tr> <tr> <th>Left (+)</th> <td>&check;</td> <td>&check;</td> <td>&check;</td> <td>&nbsp;</td> <td>&check;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <th>Left (-)</th> <td>&nbsp;</td> <td>&nbsp;</td> <td>&check;</td> <td>&check;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> </body> </html>
  4. 1 point
    As you test data contained only a menu that was a perfect match to the test order and a menu that contained everything I added a couple of extra menus and orders. SELECT m.menu_id , m.menu_name , COUNT(*) as matched , ROUND(count(*)/menuitems*100, 1) as `%menu` , ROUND(count(*)/orderitems*100, 1) as `%order` FROM ssm_menu m INNER JOIN ssm_menu_connection c ON c.menu_id = m.menu_id INNER JOIN ssm_menu_order o ON o.menu_item_id = c.menu_item_id INNER JOIN ( SELECT job_id , COUNT(DISTINCT menu_item_id) as orderitems FROM ssm_menu_order GROUP BY job_id ) jtot ON jtot.job_id = o.job_id INNER JOIN ( SELECT menu_id , COUNT(DISTINCT menu_item_id) as menuitems FROM ssm_menu_connection GROUP BY menu_id ) mtot ON m.menu_id = mtot.menu_id WHERE o.job_id = 27 GROUP BY m.menu_id ORDER BY matched DESC, `%menu` DESC, `%order` DESC; +---------+----------------------------------------------------------+---------+-------+--------+ | menu_id | menu_name | matched | %menu | %order | +---------+----------------------------------------------------------+---------+-------+--------+ | 1 | Menu One | 3 | 100.0 | 100.0 | | 2 | Private Dinner Party/Wedding - 3 Course Fine Dining Menu | 3 | 18.8 | 100.0 | | 3 | Menu Three | 2 | 66.7 | 66.7 | | 4 | Menu Four | 2 | 50.0 | 66.7 | | 5 | Menu Five | 1 | 25.0 | 33.3 | +---------+----------------------------------------------------------+---------+-------+--------+
  5. 1 point
    Tell me how to load those images into a test database and I'll continue to help.
  6. 1 point
    don't execute SELECT queries inside of loops. with today's server hardware, the time it takes for php to send the sql query statement to the database server is several times longer than the time it takes the database server to execute a query. you want to limit the number of queries you execute. postgreSQL has a LIMIT n OFFSET m statement that you should use for pagination. if for some reason you are not supposed to use that for this assignment, use php's array_slice() on the $listings array to get an array of the desired ids. then use an IN() operator to get the desired rows of data using one query. btw - the header() redirect needs an exit/die statement to stop program execution. without an exit/die, all the rest of that code is still executed. since you haven't shown us what the build_listing_card() code is or what output it produces, cannot help you with what or why your view listing links should be or don't work. don't write code like this either. every pg_fetch_result() call performs a data-seek, followed by a fetch. this takes twice as long a just fetching the data, and you have a couple of dozen pg_fetch_result() statements. the query in this code will match at most one row of data. just fetch that row into a php variable, then access elements of that fetched array. this will run measurably faster and take a lot less typing to produce the code needed for the page. if your initial long list of echo statements are for debugging purposes, just use print_r() or var_dump(), surrounded by html <pre>...</pre> tags to format the output. if this output is instead a desired part of the page output, don't spend your time typing out line after line of code for each possible field/column. use a loop and let php do the work for you.
  7. 1 point
    Only select check boxes (and radio buttons) are sent in the form data so you need you check if they are present using isset(). Example <?php for ($i=1; $i<=5; $i++) { if (isset($_GET['mycb'][$i])) { echo "Check box $i selected<br>" ; } } ?> <html> <head> <title>Example</title> </head> <body> <hr> <form> Check box 1 : <input type="checkbox" name="mycb[1]" value="1"><br> Check box 2 : <input type="checkbox" name="mycb[2]" value="2"><br> Check box 3 : <input type="checkbox" name="mycb[3]" value="3"><br> Check box 4 : <input type="checkbox" name="mycb[4]" value="4"><br> Check box 5 : <input type="checkbox" name="mycb[5]" value="5"><br><br> <input type="submit" name="btnSub" value="Submit"> </form> </body> </html>
  8. 1 point
    I'm sorry but as a policy we do not delete accounts or posts, with obvious exceptions like for spammers, and when required to by law (ie, for EU residents). If you're concerned about personal information, all we have is what you've provided - and it appears you haven't provided anything. We don't mind if you just, you know, not use your account.
  9. 1 point
    UPDATE tableZ SET x = (x = 0) WHERE id = 1
  10. 1 point
    elseif (is_numeric($minPrice)) probably needs to be elseif (!is_numeric($minPrice)) // error if NOT numeric
  11. 1 point
  12. 1 point
    This tells me you have an actual directory named 2019-holiday-party inside your gallery folder. When I created a similar directory on my end then I get results similar to yours. The problem is mod_dir which in addition to handling DirectoryIndex files, I'm not sure exactly how it's interacting with your mod_rewrite rules, but it appears as though it's triggers based on the original request url instead of the re-written URL. When it issues the redirect however it still picks up the query-string that was added to the re-written URL. This trailing slash behavior can be disabled by setting DirectorySlash Off in your configuration. That should resolve the problem, though I'm not sure it's a good solution. Another solution would be to make sure your pretty URL's don't map to an actual directory on the server.
  13. 1 point
    Or use AJAX. Depends on what you're trying to accomplish and how you're trying to accomplish it. As far as the security goes, no matter what you do that part's going to be up to you, and I'd recommend not just blindly copy/pasting code from the internet in this situation.
  14. 1 point
    Put it into a hidden input with the rest of the form that I assume you're using. And you think that Javascript is? Spoiler: it isn't.
  15. 1 point
    Are you not storing the users' answers anywhere? Write a record to the "user_response" table when a user answers a question. Then you have a record of which questions each user has answered. Only select questions for a user where there is no record in the response table for that question. SELECT Question , Answer1 , Answer2 , Answer3 , CorrectAnswer FROM question q LEFT JOIN user_response r ON q.id = r.q_id WHERE r.q_id IS NULL ORDER BY RAND() LIMIT 1 +-----------+ +-----------+ | user | | question | +-----------+ +-----------+ | user_id |--+ +----| id | | name | | | | question | +-----------+ | | | etc | | | +-----------+ | | | +---------------+ | | | user_response | | | +---------------+ | | | q_id |>-+ +--<| user_id | | test_date | | answer | +---------------+
  16. 1 point
    Jacobseated, The code was written sometime in 2013...... if that classifies as old-fashioned
  17. 1 point
    Because we're programmers. To switch to it, apparently there isn't a page I can link for you to visit, but there is a Theme selector at the bottom of probably every page. Based on Dark Theme. If you have suggestions about colors to change, reply here.
This leaderboard is set to New York/GMT-05:00
  • Newsletter

    Want to keep up to date with all our latest news and information?
    Sign Up
×
×
  • 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.