Skip to content

Tag: php

Getting Values from Laravel drop-down form

I have a simple drop-down in a form. The form is: In the view function in the controller the array is: The store function in the controller is: The method, however, stores the position of the values instead of the value itself. So, if I do a dd(request()->all());, I get: How can I get the values instead of…

Choose multiple data from datalist dropdown

I have this datalist, and right now I can only choose a signle variable, and this variable is sent with a form, and used in a sql query. But my users want to be able to pick multiple data from the datalist, but how can this be done? Can it be done by a checkbox for each option or? Part

Using ternary operator in echo?

How come I can use echo like this: But can’t use it like this Answer The ?? Operator in PHP is the Null Coalescing Operator: Since in this case expr1 is false but is set, this expression returns Boolean false. Compare: Echo does not output when passed Boolean false.

composer require phpoffice/phpspreadsheet don’t work

initially, I needed a library that will help me upload data to Excel, found this library and then there was a problem i try to install composer require phpoffice/phpspreadsheet but i have problem I don’t understand where the error comes from, because there is a dependency “ext-spltype”: “*&#…

Delete MYSQL DB Entry via PHP / HTML Button

Hey. Iam learning PHP and MYSQL atm. So i wrote already code which will display everything from my database nicely into HTML. I create also a button which says Delete. Now i want to write a Code which actually Deletes the specific entry (all have an ID ) but iam kinda lost. i know the command is: $sql = &#822…

PHP how to add data to spaces

I need to take data from a variable called $destination and add spaces between the info So example: Would return: 123 Main St But I need it to return 123%20Main%20St So I need a script that will take the data from $destination and add %20 in the spaces. Answer Use urlencode() to produce a string with percent …

Avoid Laravel redirect after validation

I’m making a simple validation on my Laravel controller: My problem is that this validation redirects me to the home if fails, and i’m making the request via AJAX, i know that Laravel detects when a request is via Ajax, but it only works if is a normal request (the typical request in which i send …