Here is the correct syntax,
for ($x=0; $x<100; $x++) {
echo "<input type=button id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>";
}
Pergunta
Trying to set an id = $x
- but it fails!
<img src='images/Rename.png' id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>
$x
is in a for()
so it starts with 1
looking at it with Firebug - it shows that the id = 0
(but the lines before it has id=1
Now, trying to - just for the test of it - set it to an input field:
<input type=button id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>
it shows in Firebug that id=1 !?
Why can't I set the id in an img tag to anything!?
Solução
Here is the correct syntax,
for ($x=0; $x<100; $x++) {
echo "<input type=button id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>";
}