是否可以有一个带有两个条件的 if esle 语句?
我有这个代码...
if ($current_page == 1)
但是我可以这样写吗
if ($total_pages ==1 $current_page < $total_pages)
我自己尝试过几种写法,但似乎无法让它工作。
任何想法,将不胜感激,
代码
echo "$current_page"; echo "$total_pages";
if ($current_page >= 1 && ($current_page < $total_pages)) { echo "next button should be here"; } else {echo "Nothing"; }
请参阅下面的链接,您可以看到它是第 1 页,共 4 页,它进入了无部分。当它应该在这里显示下一个按钮时。
php代码
$pageNum = $_GET['page'];
$engine = $_GET['engine'];
$manid = $_GET['manid'];
$mgid = $_GET['mgid'];
$file = 'http://mywebsite.com/page.xml?apikey=****&vid=****&limit=10&mgid='. $mgid.'&engine='. $engine.'&manid='.$manid.'&page=' . $pageNum;
if(!$xml = simplexml_load_file($file))
exit('Failed to open '.$file);
$total_pages = $xml->results->attributes()->totalPages;
$current_page = $xml->results->attributes()->currentPage;
$total_results = $xml->results->attributes()->totalResults;
$count = 0;
$max = 2;
foreach($xml->year as $year){
$count++;
echo '<td class="manu">'. "<a href='exact.php?manid=".$manid."&engine=".$engine."&mgid=".$mgid."&year=".$year['name']."'>".$year['name']."</a>";' </td>';
if($count >= $max){
$count = 0;
echo '</tr><tr>';
}
}
$pageNum = $current_page = $xml->results->attributes()->currentPage;
if ($current_page == 1) { } else {
echo "<a href='years.php?page=".($pageNum - 1)."&engine=".($engine)."&manid=".($manid)."&mgid=".($mgid)."'><img src='../images/previous.fw.png' width='130' height='92' /></a>";
}
echo "$current_page"; echo "$total_pages";
if ($current_page >= 1 && ($current_page < $total_pages)) {
echo "next button should be here";
} else {
echo "Nothing";