Let us assume the variable $quantity_sum_show value as 8. From the above table, Body,Material,Elastomer row field values are getting from database. I need to display the values based on the category in the table cells. Below is the sql query to fetch hno_count, hno, but confused how to display it in the table…
Tag: mysql
Laravel migration: “Foreign key constraint is incorrectly formed”)
My migration fails when I try to execute php artisan migrate or php artisan migrate:refresh with this error: Code Users Table (migrated successfully) Address Table (fails with error) Answer One of the reasons to work with a framework such as Laravel is syntactic sugar. By following their conventions, you writ…
How to create table with Foreign Keys in Laravel?
I have a users table and a roles table Now I want to create a user_role table which have two foreign keys But I’m getting an error: IlluminateDatabaseQueryException SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your Mar…
Setting up a web application using MySQL
I’m new to setting up a web based application. I have a server with MySQL setup with a database. The site is running my login web page. Currently I have users setup using MyPhpAdmin which will quickly prove burdensome. More importantly, once I run the command “$connection = mysqli_connect(‘1…
How to check duplicate but without refresh page? PHP
this is my coding. I want to check the duplicate data. If duplicate data exists, the alert will pop-out, but once I click on OK, it will go to a blank page and cannot return to the form. How to make it pop-out an alert but without refresh the page? Answer One of the solutions is to do a javascript
MySQL SUM of multiple rows from multiple table
I am trying to get the sum of multiple rows from 2 different tables, but somehow the result returns multiple rows. I need to get the SUM of quotation_item_amount (group by quotation_id) and invoice_item_amount (group by invoice_id) and if I query unpaid quotation, I need to get WHERE SUM(invoice) < SUM(quo…
I want to update the purchases table quantity value from order_item if the order is canceled in php
Please check the below code and please help me the correct syntax to used. $changeStatusSql = ” UPDATE purchases SET quantity = (select purchases.quantity+order_item.quantity as q …
How to search through unknown property name in database with Laravel
I’m trying to search database with json contains method of laravel. Here is my JSON of one database line: I want to search ID, but as you see there are numbers as properties. In example I want to find 11023235667. I’ve tried it like that: But it didn’t worked. How can I do it? EDIT: I have a…
i created a php form and connects in to mysql my all data is added in database only gender is not showing in the database
i have created a php form and connected it to mysql successfully, i created a table in mysql and added the data, all data is added except gender is not showing in database instead of gender 0 is …
Using ORDER BY and FIELD function to get single value to each custom list
I have a table named orders having 2 columns orderNumber & status as follow : orderNumber | status —————————- 10100 | Shipped | 10101 | Resolved | 10102 …