I wanted a way to make a while loop stop and wait for user input. This script just goes through numbers and stops at 5. A full implementation would be creaing database entries, and stopping when a prospective entry matched an existing entry so the user could decide whether to just use the existing entry or to go ahead and creat a new one..
<?php
$key = $_GET['key'];
if (!isset($key)) //wait for user and then restart script with key=1
{
?>
<a href="#" onclick="location='looper3.php?key=1';">start</a>
<?php
}
else //count from 1 to 10
{
while (($key < 10) && ($key != 5)) //simple while loop as long as key < 10 and not stop condition
{
echo $key . "<br>";
$key ++;
}
if ($key >= 10) //loop is over
{
echo "it's over!";
}
else //stop condition, get user to click and then restart script with key = next number
{
echo $key . "<br>";
$key ++;
?>
<a href="#" onclick="location='looper3.php?key=<?php echo $key; ?>';"><?php $show = $key-1; echo $show; ?> is cool?</a>
<?php
}
}
?>