Prafful Panwar
Prafful Panwar

Reputation: 437

input type name as $key value in php

echo form_dropdown("e_learning[$key][]",
                   $yes_no_array,
                   '',
                   'id="e_learning" 
                   class="form-control select2me"');

I want to do same thing for

<input type="number" 
       min="1" name="no_of_appointment[]" 
       class="form-control" 
       placeholder="No of Appointment">

like this

<input type="number" 
       min="1" 
       name="no_of_appointment[$key][]" 
       class="form-control" 
       placeholder="No of Appointment">

but this is not proper I am getting error Disallowed Key Characters.

I want to do this so can know which array he select according to $key value.

Upvotes: 0

Views: 868

Answers (1)

al&#39;ein
al&#39;ein

Reputation: 1727

If you want to pass PHP processed values to HTML, you have to initiate and end the PHP interpreter with the tag <?php ?>, and choose some output method.

Like:

<input type="number" min="1" name="no_of_appointment[<?php echo $key; ?>][]"
      class="form-control" placeholder="No of Appointment">

Upvotes: 1

Related Questions