-4

This question is very simple. I have an echo statement where that outputs a loop of input. Now in the input name I want to have duration(1, then 2, then 3, then 4), essentially by increments where it would output:

input 1 name=duration1
input 2 name=duration2, etc.

Here is what I have done so far:

 $numberIncrease = 0;

 echo '<a href="" id="liSpacing"><label id="labelSearch"><input class="filter" name="duration' . ++$numberIncrease . ' type="checkbox" value="' . $dur_title . '">&nbsp;$dur_title &nbsp;Day(s)</label></a> <br />';
Professor of programming
  • 2,978
  • 3
  • 30
  • 48
Jonathan Etienne
  • 621
  • 3
  • 6
  • 18
  • Maybe http://php.net/manual/en/control-structures.for.php is for you? –  Mar 25 '15 at 20:11
  • 1
    *"but that hasn't been succesful"* – what does that mean? What does it do, what do you expect it to do instead? – deceze Mar 25 '15 at 20:21
  • 1
    i meant the code is not properly worded out, and hence not producing the desire result. In particular, its not reading the increment but just the name right next to it (duration) – Jonathan Etienne Mar 25 '15 at 20:22
  • Please simply show us the result of this code and what result you'd have expected instead. That's a lot more productive than you trying to explain your interpretation of what it does. – deceze Mar 25 '15 at 20:24
  • I know you have accepted an answer, but others viewing this will likely find it hard to understand what you are asking, so for the sake of others can you reword the question, fix the issues with your code example and can you remove the tags for mysql and html5 as they do not apply. – Professor of programming Mar 25 '15 at 20:28
  • the question has been edited by the community for better clarification – Jonathan Etienne Mar 25 '15 at 20:45

2 Answers2

1

Use single quotes and concatenation instead of double quotes:

echo '<a href="" id="liSpacing"><label id="labelSearch"><input class="filter" name="duration' . ++$numberIncrease . '" type="checkbox" value="' . $dur_title . '"';
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
marian0
  • 3,336
  • 3
  • 27
  • 37
0

Change your code:

$numberIncrease = 0;
    echo 
            '<a href="" id="liSpacing">
                <label id="labelSearch">
                <input class="filter" name="duration' 
                . ++$numberIncrease 
                . '" type="checkbox" value="' . $dur_title . '">&nbsp;'.$dur_title .'&nbsp;Day(s)</label></a> <br />';
Nouman Arshad
  • 593
  • 2
  • 7