I have this code that I would like to know if there is an easier way to have it repeated. I have about 60 of these and I will always be adding more so it would be nice if someone could help me figure out a loop or something so that I won't have to manually add each one. Each of these is making a link to a download, so I am guessing I will probably have to use the variable name as the file name. The file name 01 Intro.mp3 is what tells where the download is, so I am guessing to make this work I would also have to change that to the variable name.
Here is the code I use to get the variable names.
while ($row = mysqli_fetch_array($resultstwo))
{
extract($row);
}
Here is the code that I would like to be repeated. I included two of them.
<?php
if ($intro ==1) {
$strKey = createKey();
mysqli_query($resDB,"INSERT INTO downloads (downloadkey, file, expires) VALUES ('{$strKey}', '01 Intro.mp3', '".(time()+(60*60))."')");
echo "<a href='download.php?key=$strKey'>Intro</a>";
}
?>
<?php
if ($fightingfires ==1) {
$strKey = createKey();
mysqli_query($resDB,"INSERT INTO downloads (downloadkey, file, expires) VALUES ('{$strKey}', '02 Fighting Fires.mp3', '".(time()+(60*60))."')");
echo "<a href='download.php?key=$strKey'>Fighting Fires</a>";
}
?>