PHP and Mysql - Putting textboxs into div

Asked

Viewed 84 times

0

I’m trying a kind of reverse engineering with the use of PHP, Javascript and Mysql query. I am creating an event editing form registered in a bank table.

In one of the fields, called Presence List, here is how it brings in the HTML form the value of the field listed presence within the div numPart:

<div class="BoxForm1" id="nomeParticipante">
                <br>
                <div id="numPart">
                    <?php foreach ($data['evento'] as $evento){ echo $evento['listapresenca']; } ?>
                </div>
                <input type="hidden" name="part_text" id="part_text" value="" />
            </div>

In the form that inserts a new data, the attendance list is composed of one or more textbox, depending on how many participants the event will have. Normally the field is registered as follows:

Name 1
Nome 2
Name 3
... Name 10

What I wanted was a way to transform the text of the attendance list (the text of the div numPart) in various textboxs, each going from name to new line sign

How can I do?

  • When you say 'TEXTBOX' you would be referring to <input type="textbox">? or just want to create a 'box' that will receive the list of participants?

  • echo '<input type="text" value="'. $event['presenca']. '" /><br>';

  • @Adrianoluz is the input textbox yes

  • @Daltonmenezes OK, but how can I do for more of a name saved in this field?

  • I need you to explain this better. Where would the other name be? What variable is it?

  • echo '<input name="presenca[]" type="text" value="'. $event['presenca']. '" /><br>'; Picks up the presentlist name by POST/GET where this is an array;

  • @Daltonmenezes For example, if in my table the field is stored as follows: "Name 1<br>Name 2<br>Name 3<br>". In this case it will be necessary to transform into three textbox. One containing Name 1, the other containing Name 2 and the third containing Name 3. Or as Mayron Ceccon said, if there was a way to transform into array,

  • I figured out how to do, I’ll put the solution in a new post of this topic.

Show 3 more comments

1 answer

0

I figured it out. I just had to use the blast:

<div id="numPart">
    <?php foreach ($data['evento'] as $evento){
        $participantes = explode("<br>",$evento['listapresenca']);
        for($numero=0;$numero<(count($participantes)-1);$numero++){
            echo "<div class='inputMGM'><input name='part".($numero+1)."' id='part".($numero+1)."' value='".$participantes[$numero]."' class='validate[required]'></input></div><br>";
        }
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.