-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Put each image/text pair in a div. Position with a grid layout or with left float.
-
using foreach to loop over resultset from fetch_assoc();
Barand replied to webdeveloper123's topic in PHP Coding Help
I showed you exactly how to do it in your previous topic. How do you still manage to keep screwing it up? -
Can't scrape/find 3 html tags in php simple html dom perser
Barand replied to shaadamin44's topic in PHP Coding Help
Here's a simple_html_dom/simplexml hybrid solution (the one you can't do !) $html = '<html> <body> <div class="entry-content"> <h2>hi tags?</h2> <ul> <li>some text</li> <li>sometext</li> <li>sometext</li> <li>sometext</li> </ul> <h2>hi tags2 ?</h2> <ul> <li>some text</li> <li>sometext</li> <li>To ometext</li> <li>Theometext</li> </ul> </div> </body> </html>'; $dom = new simple_html_dom(); $dom->load($html); $div = $dom->find('div[class="entry-content"]')[0]->__toString(); $xml = simplexml_load_string($div); $tags = (array) $xml->xpath("//ul")[0]->li; echo '<pre>' . print_r($tags, 1) . '</pre>';- 13 replies
-
Can't scrape/find 3 html tags in php simple html dom perser
Barand replied to shaadamin44's topic in PHP Coding Help
like this $html = '<html> <body> <div class="entry-content"> <h2>hi tags?</h2> <ul> <li>some text</li> <li>sometext</li> <li>sometext</li> <li>sometext</li> </ul> <h2>hi tags2 ?</h2> <ul> <li>some text</li> <li>sometext</li> <li>To ometext</li> <li>Theometext</li> </ul> </div> </body> </html>'; $xml = simplexml_load_string($html); $tags = (array) $xml->xpath("//div[@class='entry-content']/ul")[0]->li; echo '<pre>$tags= ' . print_r($tags, 1) . '</pre>';- 13 replies
-
- 1
-
Can't scrape/find 3 html tags in php simple html dom perser
Barand replied to shaadamin44's topic in PHP Coding Help
I was offering an alternative- 13 replies
-
using foreach to loop over resultset from fetch_assoc();
Barand replied to webdeveloper123's topic in PHP Coding Help
In this instance ther is only one order - it's items from a shopping cart -
using foreach to loop over resultset from fetch_assoc();
Barand replied to webdeveloper123's topic in PHP Coding Help
The do.. while is required in the case. the data is basically +----------+--------+ | customer | item 1 | | customer | item 2 | | customer | item 3 | +----------+--------+ We read the first row and output the customer data as the order header. In our loop we now need to output the 3 items. We still have the first row in our buffer. If we use a while loop we lose item 1 and only output items 2 and 3. The do while lets us output item 1 then loop throuugh 2 and 3 to output those also -
using foreach to loop over resultset from fetch_assoc();
Barand replied to webdeveloper123's topic in PHP Coding Help
Where, in my pseudocode, is there a while loop and a do..while loop? -
using foreach to loop over resultset from fetch_assoc();
Barand replied to webdeveloper123's topic in PHP Coding Help
set total = 0 Read first row output customer details do { output item details add item value to total } while read next row output total -
using foreach to loop over resultset from fetch_assoc();
Barand replied to webdeveloper123's topic in PHP Coding Help
RTFM once in a while. https://www.php.net/manual/en/mysqli-result.fetch-assoc.php -
using foreach to loop over resultset from fetch_assoc();
Barand replied to webdeveloper123's topic in PHP Coding Help
@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 -
using foreach to loop over resultset from fetch_assoc();
Barand replied to webdeveloper123's topic in PHP Coding Help
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? -
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.
-
Have you checked what is being sent and received by your AJAX calls? (Browser/Developr tools/Network tab)
- 3 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
Can't scrape/find 3 html tags in php simple html dom perser
Barand replied to shaadamin44's topic in PHP Coding Help
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 )- 13 replies
-
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.
-
generating invoice and getting values of quantity into an array
Barand replied to webdeveloper123's topic in PHP Coding Help
At least you now know why you can't. -
generating invoice and getting values of quantity into an array
Barand replied to webdeveloper123's topic in PHP Coding Help
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 -
generating invoice and getting values of quantity into an array
Barand replied to webdeveloper123's topic in PHP Coding Help
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. -
<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">
-
Am having problems updating this php script to work with php v8
Barand replied to wixil's topic in Third Party Scripts
@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? -
generating invoice and getting values of quantity into an array
Barand replied to webdeveloper123's topic in PHP Coding Help
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> </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'> </td></tr> <tr><td colspan='2'><b>TOTAL</b></td><td style='text-align: right;'>$inv_total</td></tr> </table> "; echo $output; ?> Giving -
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"
-
I've never changed any stream settings, so default. The forums I follow are PHP Coding SQL/Database Client Side
-
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.