I have added a custom select field and a custom text field on the checkout page in WooCommerce using the code below. I want to hide this text field by default and it should only be visible when the “Referral Program” option is selected from the select field Here is my code, which works. Except tha…
Tag: php
Insert into PDO with IF clause
I need some help with inserting some data into a sql server table using the IF clause. I have the return of an API that I insert in the table of the sql server. However, as I will schedule my code every day to get the update from the API to see if there is anything new, but every time
join a single table twice in join query
I have 3 tables users and meeting table and user_role. In user table I have user_name and user_role fields and in meeting table I have the column meeting_id assigned_username and created_by_user_name fields and In user_roles table have id and role . I want to get the assigned_user_name’s user_role and c…
If I dont use this code the instagram image is never displayed
The picture is displayed in my website only when I use this code … but if use this: It shows corrupted image like here: https://i.imgur.com/ufJHy1n.png and it happens only with instagram images because the ending of the url is not like xxxx.jpg Please help ! Answer If you had used your browser’s c…
Laravel collection – Group by months in a year and show the missing months from table with a count of 0
I am trying to create a collection in laravel which groups the current year into months with a supplied count. So far so good. The thing is, which indeed is obvious, collection is not showing the months that doesn’t exist in the table. By using the following code I get an output as follows The collectio…
I can’t get JWT token in Laravel
I am creating an API in Laravel 8 (PHP 7.4) and I wanted to secure it. The choice fell on tymon / jwt-auth. I follow the documentation from the website: https://jwt-auth.readthedocs.io/en/develop/quick-start/ Everything works fine here. However, later when I create a route to login and want to get the token u…
Combine neighbouring elemets to new array of min 2
I have a quite specific problem. I want to combine every element of an array with neighboring elements to a new array of minimum length 2. Im not sure if Im explaining that correctly so here’s an example: Given the array: I want to create a new array that looks like this: [‘abcd’] is not ret…
Images from PHPFaker got deleted when stored in storage/app/public/news folder
I have two tables news and images. These two tables have one-to-many relationship (one being news). I’m trying to make a factory on images, but right after I migrate with seed, the image saved to news directory but after one second it got deleted, and the path on the database returns news. I’ve re…
PHP topological sort
LIST: controller name => priority:required controllers sorted and expected output: First sort by priority, then reorder based on required controllers to be loaded before. ensure not to be stuck in an infinite loop due to controllers requiring each other. I assume I’ll need something like this: Please…
The cookie is not created js
I’m planning a registration system. Right now I’m trying to send a randomly generated session string to the mysql db; besides sending it on db I want to create a cookie with the js that contains the session string. I tried with the following code but I don’t know why the cookie is not genera…