Jump to content

requinix

Administrators
  • Posts

    15,288
  • Joined

  • Last visited

  • Days Won

    436

Everything posted by requinix

  1. The minus sign will also show up when a number is negative.
  2. Find out what the $request->url method is and see if there is a way you can call it so that it does not include the part of the URL you do not want.
  3. All languages that power websites, including PHP and Java and Node.js/Javascript, share the same two aspects: that there is code running on the server which creates some output, and (typically) that there is code running on the client to perform additional actions. That duality is a lot more apparent with PHP than it is, say, Node.js and React, but only because that's the more traditional (and easier) style of mixing your server-side code with your output. If you wanted to use React to handle the interface instead then you could do that with PHP too, even if the approach would be different.
  4. Named PHP functions do not work like that. There is no such thing as nesting for them.
  5. Are you familiar with your browser's developer tools? Here's a few links for Chrome, but all major browsers have something similar: https://www.codecademy.com/article/f1-devtools-box-model https://developer.chrome.com/docs/devtools/css/ https://feastdesignco.com/how-to/use-inspect-element-troubleshoot/ You can use that to find out where the extra spacing is coming from. Start by looking at the parent UL...
  6. You mean you want a line between the items? Between D/M/L and also A/B? Try adding a top border to every LI that comes after another LI: ul.dropdown-menu > li + li { border-top: ???; }
  7. PHP's gd extension doesn't support editing or outputting animated GIFs. Use something like Imagick/ImageMagick instead - which, honestly, will probably give you better quality results anyway.
  8. Using global variables means it can be very difficult to know where they are being set, or modified, or used. If you have a question or problem about one then you could have a hard time finding out what is responsible. "Attaching" is a weird way of saying "pass it as an argument". I don't know what you mean but I doubt it's a good idea. By not trying to access things outside the function at all. Use arguments and return values.
  9. This code uses a loop to fetch records, which suggests there are multiple records it might need to fetch. It does not sound like that is the case. $query_res = mysqli_query($conn, $query); while ($query_run = mysqli_fetch_array($query_res)) { The fix is simple: keep the mysqli_fetch_array but don't use a while loop. $query_res = mysqli_query($conn, $query); $query_run = mysqli_fetch_array($query_res); You can then add an if to check if that fetch returned anything. $query_res = mysqli_query($conn, $query); $query_run = mysqli_fetch_array($query_res); if ($query_run) { ... } Inside this new block is where you put your answers. After the block you add an else for the "no records found" message. $query_res = mysqli_query($conn, $query); $query_run = mysqli_fetch_array($query_res); if ($query_run) { ... } else { ... }
  10. First step: fix your code so that you do not use a loop to read a single row. Read the one single row and then output it. After you've done that, you'll know whether you have that one single row to output, and if not...
  11. First thing you have to consider is that you don't want to hit the YouTube API 25 times every time you want these numbers. Wouldn't it be nice if you could get all of them at once? And you can: take that URL you have and add all the video IDs separated by commas. And you don't need a "id" parameter if you know exactly which videos you want. Then, since there will be multiple videos in the results, you'll need to total up all the views across all of them. That means a loop. $views = 0; foreach ($jsonData->items as $item) { $views += $item->statistics->viewCount; }
  12. If you're specifying a canonical URL then using the REQUEST_URI is almost definitely wrong. Because that will result in your site claiming that the canonical URL is whatever I put into the address bar of my browser. You need to decide what that URL is supposed to be, with correct values (eg, slugs) and without any extraneous query string parameters, and provide that for the Link.
  13. Do you actually need these "shortcode" things for your site? Or do you just need to embed this number in a page somewhere? And how many videos are you talking about?
  14. Really? https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API https://developer.mozilla.org/en-US/docs/Web/API/Response
  15. If you're making your own grid layout then stop doing that and use the existing grid layout instead. https://developer.mozilla.org/en-US/docs/Web/CSS/grid
  16. As long as your preference is not to add columns for the different flavors.
  17. To be a little more clear about what I think eaglehopes is saying: The "this" in your code here let el = $(this); is not going to be the same "this" that was your Store object. You already know that: it will be the element that was clicked. However, later you then try to do this.show_price(); "this" is going to be the exact same one as it before. If you want to remember which Store object you're running with, assign "this" to a variable outside the click handler (where it will be the Store object) then reference that variable inside it.
  18. If you plug your PHPF email into https://haveibeenpwned.com you'll see it's listed in one breach: ours, that kicken linked to. I also just did a quick audit of some stuff and didn't see anything unusual.
  19. Find an API for the CRM and write PHP code to use it. You haven't given enough information to be able to answer better than that...
  20. PHP cannot create popups. If you moved from one PHP website to another PHP website then I suggest you see if you can copy what you had before.
  21. receipt_services_meta() is intended to display some HTML table of data. If you just want one value out of it, without a table, then you can't actually use the function. But you can look at the function and mirror how parts of it work. Specifically, the bits that involve the $service_time. $service_time is defined as $service_time = get_post_meta( $order_id, '_wfs_service_time', true ); so the first question is: how do you get $order_id? That came from $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id(); so next is: how do you get $order? Because that was provided to the receipt_services_meta() function by something else. If you're lucky, the $order from the first plugin may be the same as the $this->object from the second plugin. I'm skeptical, but without knowing more you might as well try it out. $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->object->id : $this->object->get_id(); $service_time = get_post_meta( $order_id, '_wfs_service_time', true );
  22. fetch returns a Promise immediately. That does not mean the Promise has been resolved yet.
  23. At the top-level you do not use awaits, and instead the Javascript runtime will handle them. As in, if it finds a dangling Promise somewhere then it will go ahead and let it run to completion. That's why you can call fetch().then().catch() without having to await anything yourself. You also do not need to use await inside the .then(). It's okay to return a Promise, which is what .json() will return. That Promise it returns then gets "unwrapped" before the next .then kicks in. In other words, why are you adding async/await in the first place? Is there a reason, or are you just trying to learn more about it?
  24. Are you sure that URL is returning what you expect? What do you see if you console.log the whole data object?
×
×
  • 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.