<?php
$files = glob( 'docs/*.xml' );
if ( isset( $_GET['doctype'] ) == "all" ) {
foreach ( $files as $file ) {
$xml = new SimpleXMLElement( $file, 0, true );
echo'
<tr>
<td id="'. $xml->doctype .'" name="'. $xml->doctype .'" class="mainTable">' . $xml->doctype . '</td>
<td><a href="viewdoc.php?docname=' . basename( $file, '.xml' ) . '&username='. $xml->startedby .'&myname='. $_SESSION['username'] .'">' . basename( $file, '.xml' ) . '</a></td>
<td><a href="viewprofile.php?name='. $xml->startedby .'">'. $xml->startedby .'</a></td>
<td>'. $xml->date .'</td>
<td>* * * * *</td>
<td>'. filesize( $file ) .'kb</td>
</tr>
';
}
}
else if ( isset( $_GET['doctype'] ) == "doc" ) {
foreach ( $files as $file ) {
$xml = new SimpleXMLElement( $file, 0, true );
// code filter the $xml->doctype by equal it to currect value - which i'm not sure how to do.
echo'
<tr>
<td id="'. $xml->doctype .'" name="'. $xml->doctype .'" class="mainTable">' . $xml->doctype . '</td>
<td><a href="viewdoc.php?docname=' . basename( $file, '.xml' ) . '&username='. $xml->startedby .'&myname='. $_SESSION['username'] .'">' . basename( $file, '.xml' ) . '</a></td>
<td><a href="viewprofile.php?name='. $xml->startedby .'">'. $xml->startedby .'</a></td>
<td>'. $xml->date .'</td>
<td>* * * * *</td>
<td>'. filesize( $file ) .'kb</td>
</tr>
';
}
}
?>
我有几个<a>
标签(相同的链接,home.php),每个都有不同的 $_GET 链接(home.php?doctype=doc,home.php?doctype=all,等等)。现在我希望使用 if 语句过滤每个 doctype 并检查$_GET['doctype']
他是否等于我的值(假设值是 word、excel、powerpoint 等)。
我的问题是:假设我将 $xml->doctype 等于我的值之一,我该如何过滤 doctype?