PHP is the easiest way to do this?
I am checking a column called seasons in MySQL using PDO, but how would I go to check how much time is in seasons and echo depending on what it contains, for example, say it is 3, it outputs it all into one echo:
<a href="season 1">Season 1</a>
<a href="season 2">Season 2</a>
<a href="season 3">Season 3</a>
But what if it checks for some other string and that there are 5 rows in season, I would need to echo:
<a href="season 1">Season 1</a>
<a href="season 2">Season 2</a>
<a href="season 3">Season 3</a>
<a href="season 4">Season 4</a>
<a href="season 5">Season 5</a>
This is all done in one index.php file and its main load dependency is the parameter named? name = Basically, the name determines which line to check for all this.
How should I do it?
Update:
<a href=".$dl.$dl720p1.$ref.">Season 1</a>
<a href=".$dl.$dl720p2.$ref.">Season 2</a>
<a href=".$dl.$dl720p3.$ref.">Season 3</a>
<a href=".$dl.$dl720p4.$ref.">Season 4</a>
Update:
$seasons = 1;
while (isset(${'dl720p' . $seasons})) $seasons++;
for ($i = 1; $i < $seasons; $i++)
$download = '<a download class="download-torrent button-green-download-big" onclick="window.open(this.href,\'_blank\');return false;" target="_blank" href="' .$dl . ${'dl720p' . $i} . $ref. '"><span class="icon-in"></span>Season ' . $i . '</a>' . "\n";
+3
source to share
1 answer
So, are you displaying links based on how many there are? Try the following:
<?php
$dl720p1 = 'one';
$dl720p2 = 'two';
$dl720p3 = 'three';
$dl720p4 = 'four';
$dl720p5 = 'five';
$seasons = 6;
$dl = 'a';
$ref = 'b';
$download = '';
for ($i = 1; $i <= $seasons; $i++)
$download .= '<a href="' .$dl . ${'dl720p' . $i} . $ref. '">Season ' . $i . '</a>' . "\n";
echo $download;
Output :
<a href="aoneb">Season 1</a>
<a href="atwob">Season 2</a>
<a href="athreeb">Season 3</a>
<a href="afourb">Season 4</a>
<a href="afiveb">Season 5</a>
+5
source to share