Reputation: 136
I'm developing a website where people can vote on youtube videos.
In my toplist I have an upvote button. I generate it with php code, but on the first video it does not generate the form for the first button.
Here is the code:
echo "
<tr>
<th scope='row'>$i</th>
<td>$title</td>
<td>$vote</td>
<td>
<a style='color: #00bcd4;' href='https://www.youtube.com/watch?v=$url' target='_blank'>
Watch
</a>
</td>
<td>
<form method='post' action='sendmusic.php'>
<input value='https://www.youtube.com/watch?v=$url' type='hidden' name='url'>
<input type='hidden' value='upvote' name='name'>
<button type='submit' class='mdl-button mdl-js-ripple-effect mdl-js-button mdl-button--raised mdl-button--colored'>Upvote</button>
</form>
</td>
</tr>
";
Upvotes: 1
Views: 639
Reputation: 25525
why wouldn't you just do:
for ($i = 0; $i <= 10; $i++):
?> <!-- close php -->
<tr>
<th scope='row'><?php echo $i ?></th>
<td><?php echo $title ?></td>
<td><?php echo $vote ?></td>
<td>
<a style='color: #00bcd4;' href='<?php echo "https://www.youtube.com/watch?v=$url" ?>' target='_blank'>
Watch
</a>
</td>
<td>
<form method='post' action='sendmusic.php'>
<input value='<?php echo "https://www.youtube.com/watch?v=$url" ?>' type='hidden' name='url'>
<input type='hidden' value='upvote' name='name'>
<button type='submit' class='mdl-button mdl-js-ripple-effect mdl-js-button mdl-button--raised mdl-button--colored'>Upvote</button>
</form>
</td>
</tr>
<!-- open php -->
<?php
endfor;
Upvotes: 3