mysqli

Move data from one table with button to another table Laravel

ε祈祈猫儿з 提交于 2020-01-15 05:25:07
问题 Before someone say this is a duplicate. Yes i have found this: Move data from one MySQL table to another But in Laravel its a bit different this is quiet that what i want. Like him i want a button wich delete a row in a tabel like this one: (Updated picture) Just to have an example. After he hit the button it should move the shown row into the database just like it is shown here and delete it afterwards. I really dont know how to start something like this in laravel and i really cant find

Search feature with multiple criteria - PHP/MySQL

放肆的年华 提交于 2020-01-15 05:11:08
问题 How can i create a search page with multiple criteria where at least a criteria should be checked. Table Structure ID [pk] Name Sex Location I want to create a search form where user will be able to search by name or by name,sex or by name,sex,location or any such combination among [name,sex,location] How to design the query ? Edit i am not asking for checking atleast a single option has value [js validation], i am asking for the query ! I'll use mysqli prepared statement ! 回答1: You can check

When does a prepared statement fail?

一个人想着一个人 提交于 2020-01-15 05:06:20
问题 I've been messing around with the MySQLi object in PHP , and was getting used to preparing statements before executing them. Thus far I've mostly been doing the following : if($stmt = $mysqli->prepare($sql) == false){ return $mysqli->error; } Which, when it failed, has always told me that my SQL was wrong basically. Assume the following : A check has been done to ensure MySQL connectivity The SQL is correct, even if it returns 0 rows. All relevant tables exist. Under what circumstances could

When does a prepared statement fail?

不问归期 提交于 2020-01-15 05:06:08
问题 I've been messing around with the MySQLi object in PHP , and was getting used to preparing statements before executing them. Thus far I've mostly been doing the following : if($stmt = $mysqli->prepare($sql) == false){ return $mysqli->error; } Which, when it failed, has always told me that my SQL was wrong basically. Assume the following : A check has been done to ensure MySQL connectivity The SQL is correct, even if it returns 0 rows. All relevant tables exist. Under what circumstances could

Can SELECT, SELECT COUNT and cross reference tables be handled by just one query?

被刻印的时光 ゝ 提交于 2020-01-14 19:26:06
问题 I have a page that displays a list of projects. With each project is displayed the following data retrieved from a mysqli database: Title Subtitle Description Part number (1 of x) The total number of photos associated with that project A randomly selected photo from the project A list of tags Projects are displayed 6 per page using a pagination system As this is based on an old project of mine, it was originally done with sloppy code (I was just learning and did not know any better) using

Using bind_param with arrays and loops

 ̄綄美尐妖づ 提交于 2020-01-14 19:14:10
问题 according to this example for prepared statements I first bind parameters and then set values for the parameters. Let's assume I have a 2-dim array $alias $array1 = [ 'id' => 1, 'tstamp' => 123456789, 'alias' => '$alias', ]; $array2 = [ 'id' => 1, 'tstamp' => 123456789, 'alias' => '$alias2', ]; $alias = [$array1, $array2]; Why is this code working $insert = 'INSERT INTO abcdef VALUES (?,?,?)'; $insertStmt = $conn->prepare($insert); foreach ($alias as $array) { $insertStmt->bind_param('iis',

Insert NULL instead of empty values using MySQLi

五迷三道 提交于 2020-01-14 15:55:55
问题 I have a form with some optional fields. In the database those fields are set to accept NULL. The code below will throw an error if some field is empty. Could you please assist on what is the best way to avoid this? The only solution I was thinking of is to set the vars to ' ' if is empty(). $query = "INSERT INTO gifts (dateRequest, firstName, lastName, note, lastUpdated) VALUES (?, ?, ?, ?, NOW())"; if ($stmt = $dbc->prepare($query)) { $dateRequest = $_POST['dateRequest']; $firstName = $

Its outputs details incorrectly in php/html

只愿长相守 提交于 2020-01-14 12:18:07
问题 I want to display all the questions from the drop down menu when the user selects All from the question drop down menu and output it underneath. Problem is that it is not doing this and to make it worse, it is giving me undefined offset errors stating: Notice: Undefined offset: ... in .... on line 605 Line 605 is: echo '<p><strong>Question:</strong> ' .htmlspecialchars($arrQuestionNo[$key]). ': ' .htmlspecialchars($arrQuestionContent[$key]). '</p>' . PHP_EOL; My question is how to fix the

Its outputs details incorrectly in php/html

江枫思渺然 提交于 2020-01-14 12:11:11
问题 I want to display all the questions from the drop down menu when the user selects All from the question drop down menu and output it underneath. Problem is that it is not doing this and to make it worse, it is giving me undefined offset errors stating: Notice: Undefined offset: ... in .... on line 605 Line 605 is: echo '<p><strong>Question:</strong> ' .htmlspecialchars($arrQuestionNo[$key]). ': ' .htmlspecialchars($arrQuestionContent[$key]). '</p>' . PHP_EOL; My question is how to fix the

Its outputs details incorrectly in php/html

不想你离开。 提交于 2020-01-14 12:10:10
问题 I want to display all the questions from the drop down menu when the user selects All from the question drop down menu and output it underneath. Problem is that it is not doing this and to make it worse, it is giving me undefined offset errors stating: Notice: Undefined offset: ... in .... on line 605 Line 605 is: echo '<p><strong>Question:</strong> ' .htmlspecialchars($arrQuestionNo[$key]). ': ' .htmlspecialchars($arrQuestionContent[$key]). '</p>' . PHP_EOL; My question is how to fix the