Hopefully this will be the last piece of the puzzle. I have text fields for each unit where a commitment date must be entered. I am using a foreach loop but when I var_dump it I can see way too many units.
Here is my html table. I am storing the unit key in a hidden field
When testing, if I var_dump the commitment date, I get three dates for 3 text fields and the output matches what I inputted. The units however looked like this.
text fields for each unit where a commitment date...
If it's a date, you probably want to use a DATE field for that column.
To go any further with this we should see the CREATE TABLE statements and the queries you're using. We also need to see the fully resolved HTML that is in play.
Crazy Horse
ASKER
Thanks, Ray. In the database I am using a DATE field for that column, but a text input in the HTML with a date picker. I will post all the required code when I get back onto my development pc.
Regarding the created table statements, I create all my tables and columns in phpMyadmin. Would I manually need to type out the CREATE TABLE statements for you or is there a way to generate them from already created tables in phpMyadmin?
Ray Paseur
You can generate them with SHOW CREATE TABLE - very handy!
You might want to learn about the "Laravel way" of creating database migrations and seeding. In practice, it stumbles over Git branches a little bit, but it gives you a clear path from the "big bang" of application origin to a current state for your database. Also very handy!
Aha, nice one! Okay, so I hope this is enough info. Please let me know if not.
CREATE TABLE `units` ( `id` int(11) NOT NULL AUTO_INCREMENT, `u_key` int(11) NOT NULL, `entry_date` date NOT NULL, `commit_date` date NOT NULL, `complete_date` date NOT NULL, PRIMARY KEY (`id`)
I tried adding a second foreach but that just takes the input from the last textfield and inserts the same data for every row.
foreach($_POST['commit_date'] as $commitdate) {foreach($_POST['u_key'] as $unit) {$stmt = $link->prepare("UPDATE `repair_tanks` SET `commit_date` = ? WHERE `u_key` = ?");$stmt->bind_param("si", $commitdate, $unit);$stmt->execute();$stmt->close();
To go any further with this we should see the CREATE TABLE statements and the queries you're using. We also need to see the fully resolved HTML that is in play.