<?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>
';
}
}
?>
I got few <a>
tags (same link, home.php), each one got different $_GET link (home.php?doctype=doc, home.php?doctype=all, etc..).
Now i wish to filter each doctype by using if statement and check $_GET['doctype']
if he equals to my value (assuming the value is word, excel, powerpoint, etc..).
My question is: how can I filter doctype assuming that I equal $xml->doctype to one of my values?