Skip to content

Tag: php

How can I execute PHP code with Powershell?

I’m building a website and I want to monitor a folder for changes, and when those changes happen I want to start my PHP script, which runs an SQL query to builds my table. Here is the script: This is largely from nixda, so credit goes to them Answer To synchronously execute console applications or batch…

Index an array using a callback function to get the key

Is there a built-in PHP function that does the following? I think I’ve reviewed all array_*() functions, but am surprised that this use case is not covered by any native function. Answer There’s no built-in function that does this in one step. But you can use array_map() to get the new keys from t…

Ajax JSON.parse JSONarray

I am trying populate a form from a mysqli database when an option is selected from a drop down. I am trying to do this with an ajax ‘get’ call to a PHP page. The PHP page does the SQL query and returns the results, then I do a json_encode of the data. This puts the JSON into an array.

Button not showing selected on tab load from jquery

When I load the page normally, it will display corrected. However when attempting to load the tab through the url IE: page.php#tab2, the tab navigation will not select the tab I am currently on and will instead load the default tab “tab1” jquery: html: What it’s doing… https://i.stack.…

Laravel Relationship Getting All Children

I have a query which returns a table. I would like to also return a list of styles which relate to it from another table. I have tried many things but I can’t find one which works. Any advice? Query: YarnOrderLines: YarnOrderLineStyles (table with relating styles in I would like to pull in) Answer You&#…

Use explode on array?

What’s the easiest way to turn the array into Is there something built-in with laravel/collections that I can use? I know I can make a foreach loop and use explode and populate a new array, but I’m wondering if there is a built-in function in PHP or a laravel collections method I can use. Answer I…

PHP odbc_exec not returning all rows

This simple query when run in DBExplorer (a DB tool for executing raw SQL queries), returns 5 rows (contents of an invoice). Everything is setup in such a way that an invoice may contain multiple goods of the same ID (but with different prices and procurement prices, printing names – e.g. bucket-white, …