我正在使用pdo检查mysql中一个名为seasures的列,但是我如何检查seasures和echo中的值取决于它包含的内容,例如,假设它是3,它将在一个echo中输出所有这些:
<a href="season 1">Season 1</a>
<a href="season 2">Season 2</a>
<a href="season 3">Season 3</a>
但如果它检查其他行,而该行的季节包含5,我需要它来回应:
<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>
这一切都在一个文件index.php中完成,它的主要依赖性是一个名为?name=基本上,名称决定了要检查的行。
我该怎么做?
更新:
<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>
更新:
$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";
最佳答案
所以你是根据有多少个链接输出的?试试这个:
<?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>