Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP code isn't allowing multiple input values to send through my form

Tags:

html

php

I am running into a wall with an application I have built. I am brand new to PHP (less than 1 month) and I have written a very complex form with the help of a mentor. Due to a confidentiality agreement I cannot send my entire code here for an example. Specifically the issue I am having is that my form isn't able to send multiple values to two different input "slots". It will send a singular input value to the database, but it should be registering the different values inputted.

<?php                        
{
foreach($results['tags'] as $part){
if ($part['category'] == "Part"){
?>
<tr>
<td><?= $part['Part']; ?></td>
<td class="text-center"><?= $product['Amount']; ?></td>
<td><input type="text" name=$product['Val1'] /></td>
<td><input type="text" name=$product['Val2'] /></td>
</tr>

<?php
    }
      }

         }

            ?>

My mentor suggested this as an answer but I am not sure what he means: "It seems like the [val1/2] needs to be tied to the product instead of the transaction. Right now, it’s not inside that “tags” section. Does that make sense?"

like image 424
Shea Price Avatar asked Aug 12 '26 04:08

Shea Price


1 Answers

You're trying to name your vars with $. I suppose you want to output php values there, so change your string to look like this:

<td><input type="text" name="<?= $product['Val1'] ?>"/></td>
like image 184
Denis Alexandrov Avatar answered Aug 14 '26 12:08

Denis Alexandrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!