I have a little problem with my PHP-class/function which adds data to my mySQL DB. There is a form in html/php which calls a function on submit to insert data into the DB. Inside the form there is a date-field which is optional to fill out. When I now pass the form data to my function to insert to the
Tag: mysql
How can i create dynamic menu with sub-menu with php & mysql?
I’m trying to create an dynamic menu from mysql table with php but i don’t know how to create the non category menu, here is what i have so far and is working only the categories with submenus but the non categories ones they are not shown on echo. MySQL category menu Table: MySQL sub menus Table:…
One big update query, or several single update queries, to update a value in MySQL multi-tenant database
I’m working in a ‘point of sale’ application (PHP + MySQL), with products, sales, product quantity that have to be updated (+ or -) depending on the operation (sale/buy), etc. On every sale/buy, I save the operation data (date, customer, totals…) in an ‘invoices’ table, and…
default values in input form Modal
I just created a datatable collecting the values from a wordpress database.- These values must be loaded in a contact form within a modal. I am calling the modal from a button in the last column of each row of the datatable. I must predetermine the values of the form fields with the information correspo…
Updating and deleting from a data table, warning undefined array key
I have been following a lesson on how to make an admin page. I got all the information out of my database to a table on the page. I have an update button and when I change the information and press the button I receive this error: Warning: undefined array key “WebID” in ..Update.php on line 3 From…
Cannot union two Joints Laravel
Im trying to union 2 joins, but im getting weird error… I have “Clientes” -> means clients, and i got all the clients that they got registered in orders and news. In news table i got the cliente_id -> client_id , And in orders, i got the same, cliente_id -> client_id, In news i got …
How to compare tables from different mySQL databases with PHP?
I’m new to PHP as well as the field and have been tasked with finding inconsistencies amongst tables from different mySQL databases. Every table should be the same between databases (column names, column count), with the exception of the actual data held in it, which they are not. I will need to identif…
How to get foreign key from eloquent collection in laravel
I have hasMany relationship in my User model; I need to get a foreign id in Eloquent data Controller; Expected output; 1 How can I get the foreign key? Answer You can do the following. Since posts has hasmany relation so it return collection of object even though you have one item in posts. or If you still ne…
Laravel migrations won’t apply on MySQL (InnoDB)
Hello everyone, This is my first time posting ! I am running into a problem when applying laravel 8 migrations on my new web server. While trying to deploy my projet I’m unable to apply migrations and I’m not sure why. Below images of the error and my migration, i’m using the php artisan mig…
Insert into MySQL table if no row added within 5 minutes
I have a table which contains a column consisting of timestamps. I want to check if there is a new row within 5 minutes period of time. If not, then insert a new row or update the last row status column. I tried something like this: or insert into … but no success so far. I’m using PHP in WordPres…