Jump to content

Barand

Moderators
  • Posts

    24,606
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. Where, in my pseudocode, is there a while loop and a do..while loop?
  2. set total = 0 Read first row output customer details do { output item details add item value to total } while read next row output total
  3. RTFM once in a while. https://www.php.net/manual/en/mysqli-result.fetch-assoc.php
  4. @ginerjm It won't work! You're loop will now print only the last two ordered items - you've thrown the first one way. That is why there was a do..while() loop. Read first row output customer details do { output item details } while read next row
  5. You fetch a row then print_r() it to see what it contains. Why are you surprised that it only shows the one row that you fetched?
  6. There appears to be a line missing from your code - the line where you take each row from your "$result1" and put them into "$item". For future reference, please post in English and tell us what the probem is and any error messages you might be getting.
  7. Have you checked what is being sent and received by your AJAX calls? (Browser/Developr tools/Network tab)
  8. Maybe $xml = simplexml_load_string($html); $ul = $xml->xpath("//ul"); $tags = (array) $ul[0]->li; $tags= Array ( [0] => some text [1] => sometext [2] => sometext [3] => sometext )
  9. Check the names of the input in your form. These POST fields don't exist $myName = addslashes( $_POST['name'] ); $myClass = addslashes( $_POST['class'] ); $myGender = $_POST['sex']; PS Find some recent tutorials - your HTML markup code is a decade or two out of date and deprecated. Use prepared statements instead of embedding user-provided data in your SQL.
  10. Not quite the same https://www.php.net/manual/en/control-structures.while.php https://www.php.net/manual/en/control-structures.do.while.php
  11. Why are you using both a while() loop and a do..while() loop? When the while loop finishes there a re no rows left to read. I showed you how to do it. Apparently that was a total waste of my time.
  12. <form action="comment.php?post_id=<?php $_GET['post_id'];?>" method="post"> That code will generate a link with no id value, like this... <form action="comment.php?post_id=" method="post"> It needs to be either <form action="comment.php?post_id=<?php echo $_GET['post_id'];?>" method="post"> or <form action="comment.php?post_id=<?= $_GET['post_id'] ?>" method="post">
  13. @mac_gyver's first reply told you what was wrong with that line - yet there it is again, unchanged. If you ain't listening why are you posting?
  14. Here's a mysqli version <?php include '../db_inc.php'; $link = myConnect('test'); $last_id = 1046; $invoice="SELECT order_details.order_id , DATE_FORMAT(orders.order_date, '%M %e %Y') as order_date , concat(customer.first_name, ' ', customer.last_name) as customername , customer.address , customer.town , customer.county , customer.post_code , product.name as productname , order_details.qty , order_details.qty * product.price as amount FROM order_details JOIN orders ON orders.order_id = order_details.order_id JOIN customer on customer.customer_id = orders.customer_id JOIN product ON order_details.product_id = product.product_id WHERE order_details.order_id = $last_id"; $invoiceOutput = $link->query($invoice); $inv_total = 0; $row = $invoiceOutput->fetch_assoc(); // READ 1st ROW OF RESULTS // RETRIEVE AND OUTPUT THE INVOICE HEADER STUFF $output = "<table style = 'width: 400px;'><tr><td><b>Customer<b></td><td>{$row['customername']}</td></tr> <tr> <td>&nbsp;</td> <td> {$row['address']}<br> {$row['town']}<br> {$row['county']}<br> {$row['post_code']}<br> </td> </tr> <tr><td><b>Order No<b></td><td>" . sprintf('%06d', $last_id) . "</td></tr> <tr><td><b>Order Date<b></td><td>{$row['order_date']}</td></tr> </table><br><br> <table style='width: 500px; border-collapse: collapse;'> <tr style='background-color:#000; color: #FFF'> <td><b>Product</b></td> <td><b>Quantity</b></td> <td style='text-align: right;'><b>Amount</b></td> </tr> "; do { // LOOP THROUGH RESULTS OUTPUTTING DETAIL LINES $output .= "<tr><td>{$row['productname']}</td> <td>{$row['qty']}</td> <td style='text-align: right;'>{$row['amount']}</td> </tr>"; $inv_total += $row['amount']; } while ($row = $invoiceOutput->fetch_assoc()); // OUTPUT THE TOTAL $output .= "<tr><td colspan='3'>&nbsp;</td></tr> <tr><td colspan='2'><b>TOTAL</b></td><td style='text-align: right;'>$inv_total</td></tr> </table> "; echo $output; ?> Giving
  15. I think that's the only time I've seen that behaviour. I usually look at the notifications but then go to the activity (condensed) list and go to the topic from there. That way I can see if they've been responded to already or not. On that occasion the notified topic wasn't there - normally they are there pretty much straight away. The heading at the top is "All Activity"
  16. I've never changed any stream settings, so default. The forums I follow are PHP Coding SQL/Database Client Side
  17. To keep the debate lively I'll throw in another option - store the answers in an html form's input fields. When they finish they can submit or start again. You could show the questions one at a time, using javascript to hide the one just answered and display the next.
  18. I think they appeared about an hour later when there was another comment on same topic. An hour is long lag for what is essentially the same data, slightly different query
  19. After writing my version I compared it to yours and noticed it was almost identical to your subquery. Your version only needed the query you have in the subquery (+ HAVING clause + ORDER BY). The rest was completely superfluous.
  20. Activity (condensed mode) is losing topics). Today I had 2 notifications for a topic Which appear in the expanded activity page But have disappeared from the condensed version
  21. Yes, it's to preserve the price at which the product was sold so that historical reports can use that price and not the price it is currently being sold at (if at all). Keeps the accounting straight.
  22. Does this give what you need? SELECT roster_no , drill_date , count(distinct drill_no) as drills FROM mms_drills JOIN mms_drillatt USING (drill_no) WHERE YEAR(drill_date) = '2022' AND description Not Like '%National%' GROUP BY roster_no, drill_date HAVING drills > 1;
  23. What are the keys on those table?
  24. As in Test data : that data for which the query works
×
×
  • 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.