Reputation: 117
<!doctype html>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?php
$x = 5;
while($x>0)
{
echo 'Line' . $x;
echo "<br>";
$x--
}
?>
</body>
</html>
Now, along with the output i want to create 5 submit buttons. one button will be created in each iteration of the loop above. is it possible?
Upvotes: 0
Views: 1685
Reputation: 1005
Try this, just echoing <input type=submit>
.
$x = 5;
while($x>0)
{
echo 'Line' . $x;
echo '<input type=submit value="button '.$x.'"></input>';
echo '<br>';
$x--
}
Upvotes: 0
Reputation: 94
try to use href will be better. if you use submit button it need create 5 different form and the code will look messy.
try this:
<?php
$x = 5;
while($x>0)
{
echo 'Line' . $x;
echo "<a href='test.php?a=$x'>test</a>";
echo "<br>";
$x--
}
?>
after that :
call the value in other page :
if($_REQUEST['a'] == '1'){
//code here
}
else if($_REQUEST['a'] == '2'){
//code here
}
......
Upvotes: 3