Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. You have to iterate through the array and compare each value to $b, when you find a match return the key.
  2. As davej said, the main problem is that you're treating x as a string when it's an HTML element. Aside from that, you shouldn't have a global variable called "location" because it's masking the window.location object. Make it local by declaring it with the var keyword.
  3. ECMAScript 6 is mainly geared towards programmers. Most people use Javascript for simple effects on the page, they won't need to make use of the new features, so I wouldn't suggest teaching it to beginners. The way Javascript is used today won't change for people who are not building large browser applications.
  4. The number_format() function is used for that: http://php.net/number_format Here's an example: echo number_format(1500123.26441, 2, ',', '.');
  5. Just use inputs in the form to identify it. In form 1: <input type="hidden" name="action" value="form1"> In form 2: <input type="hidden" name="action" value="form2"> On the server side: $action = isset($_POST['action']) ? $_POST['action'] : ''; switch($action) { case 'form1': // Do processing for form 1 break; case 'form2': // Do processing for form 2 break; default: echo 'Invalid form'; }
  6. I do not trust any Microsoft Office products to generate a proper web page that works correctly in all browsers. Of course it will work in Internet Explorer, that's MIcrosoft's own browser. I can't remember now, but I think there was a "raw html" option in the export settings, which may work better. If that's not correct, then upload it to Google Drive and try to have Google Drive export it to a better format. If you want a page to look correct on all browsers you usually have to write the code yourself.
  7. PHP has a set of MYSQLI_TYPE_* constants that identify the field type. The list of them is here: http://php.net/manual/en/mysqli.constants.php
  8. You can't put setNote() there because it doesn't return anything and it sends headers. setNote() should only be called when you're not printing the form, it should be at the very beginning of your code before anything is printed.
  9. You haven't shown enough code to determine what the issue is. Where are the setNote() and getNote() functions being called? You cannot call setNote() after you have called getNote().
  10. You cannot print any content at all before you send a header. No echo statements and no content outside of <?php ?> tags. Headers are always sent before the page content.
  11. They don't seem to want their forum to be found. It's a small link in the footer. Is your icon one of your illustrations?
  12. The demo worked properly for me. It would break if you saved the file with the wrong encoding. Unicode characters are useful so that the user doesn't have to download images or web fonts.
  13. Ingolme

    Diagonal border

    Who else have I heard yelling "wrong!"? I do know about it, it just slipped my mind. The major drawback of this approach that the content inside the container ends up skewed as well. You'll need to add extra elements or pseudo elements to account for the top and bottom borders.
  14. You can use media queries to set the height of something explicitly. .object { height: 200px; } @media (max-width: 1024px) { /* Devices up to 1024 pixels wide */ .object { height: 100px; } }
  15. Ingolme

    Diagonal border

    That's beyond the capabilities of CSS, CSS just works with rectangular boxes and the optional rounded borders. You could draw the border using SVG and use that as a background image.
  16. In bootstrap, there's a class called "img-responsive" for images which basically sets the max-width to 100% and height to "auto". If it's a background image, with CSS you can set the background-size property to "cover".
  17. The arrows are in the HTML and they are unicode characters. Make sure your page is encoded in UTF8. You could replace them with an image or web font icon.
  18. You can't see the date, but you can check the source code to see if the meta tag has the value you expected it to have.
  19. You can see Google's latest crawl of your site by searching for "cache:brauli.cl" www.google.com/?q=cache:brauli.cl It hasn't crawled your site again yet, it could take a week.
  20. My guess is that the request is actually being sent as GET, the network tab should have shown that, but I can't tell because the request information isn't visible in the screenshot.
  21. The w3-accordion class seems to be built for links to be styled as a navigation element, so generally the accordion content would be nothing but a set of links and they would be styled as blocks. Here's the CSS that's being applied to the link: .w3-accordion-content a { padding: 6px 16px; display: block; } You can add a rule like this to your own stylesheet to override it. .w3-accordion-content p a { padding: 0; display: inline; }
  22. Forget the status, what's the actual response? You can see what was sent and what was received in the network tab. Look at the request headers and look at the response body.
  23. Ingolme

    pdo while loop

    I don't usually test code when I write it for the forum. My hope is that you'll understand the theory behind it and learn from it. If you understood it correctly you should be able to fix any mistakes I made.
  24. Ingolme

    pdo while loop

    There's a variable inside the prepared statement, you should never put variables directly in the statement, use a placeholder and pass the variable in using bindParam. You're overwriting variables $query and $row from outside the loop, which will cause it to stop looping through rows of the first query. When calling fetchAll(), you get an array that you have to loop through, but in your code you're not looping through that array, instead you called the fetch() method which gets only the first row. Prepared statements only have to be prepared once, preparing it inside the loop is inefficient. I've fixed your code, you should use more descriptive variable names so that you don't overwrite them. function cart_display() { global $db; // Get IP address $ip = getIp(); // Prepare the cart statement $cart_query = $db->prepare('SELECT p_id FROM cart WHERE ip_add = :ip'); $cart_query->bindParam(':ip', $ip); // Execute the statement $cart_query->execute(); // Prepare the next statement to be used in the loop $product_id = ''; // Initialize variable $product_query = $db->prepare("SELECT * FROM product where product_id = :product_id"); $product_query->bindParam(':product_id', $product_id); // Loop through results of the first query and execute the second query while($cart = $cart_query->fetch(PDO::FETCH_ASSOC)) { // Thanks to the magic of bound parameters // $product_id is automatically passed into the query $product_id = $cart['p_id']; $product->execute(); // Loop through products while($product = $product_query->fetch(PDO::FETCH_ASSOC)) { // Print a table row with product values echo " <tr> <td><input type = 'checkbox' name='remove[]' value='{$product_id}'/> </td> <td>{$product['product_name']} <br><img src='admin/product_images/{$product['product_image']}' width='80' height='80'/></td> <td><input type='text' name='qty' value='{$row['qty']}'/></td> <td>{$product['product_price']}</td> </tr> "; } } }
  25. It is preferable to have code that validates, but don't judge us all by just one forum member. To fix the remaining validation issue, just put a <title> element in the head. To fix your first issue, each time a button is clicked, hide all of the menu elements, then show the one you need: // For each button, assign an event handler var acc = document.getElementsByClassName("accordion"); for (var i = 0; i < acc.length; i++) { acc[i].addEventListener("click", accordion); } // Event handler function function accordion() { // Reset all of the elements for(var i = 0; i < acc.length; i++) { acc[i].classList.remove("active"); acc[i].nextElementSibling.style.maxHeight = null; } // Toggle the "active" class for the current item this.classList.add("active"); // Make the contents visible var panel = this.nextElementSibling; panel.style.maxHeight = panel.scrollHeight + 'px'; } I am not experiencing the second issue you described. The container should expand to fit all its content, unless the content exceeds the browser's height.
×
×
  • Create New...