แต่ตอนนี้ยังติดที่ เงื่อนไข มันใช้ได้แค่ if (isset($_POST['sname']) == "selectcard") มันไม่ยอมไปอีกเงื่อนไขนึง ไม่ทราบว่าเป็นเพราะอะไร
โค้ด: เลือกทั้งหมด
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<h1 id="badges" class="page-header">Php show image from folder # Thebest Jantararat</h1>
<form action="3.php"method="post" enctype="multipart/form-data">
<select name="sname">
<option value="" selected="selected">Please select folder</option>
<?php
foreach(glob(dirname(__FILE__) . '/t1/*') as $filename){
$filename = basename($filename);
echo "<option value='" . $filename . "'>".$filename."</option>";
}
?>
</select>
<input class="button" type="submit" value="แสดง" />
</form>
<?php
$img="";
$folder="";
if (isset($_POST['sname']) == "selectcard")
{
echo "ยังไม่เลือกโฟลเดอร์ หรือ เขียนโค้ดผิด" ;
}
else if(isset($_POST['sname']) == "1")
{
//echo "ยินดีด้วยโค้ดเขียนถูก" ;
$img=$filename;
}
?>
<?php
$folder=$img;
$files = glob($folder."/*.*");
echo '<h3>รูปภาพทั้งหมด <span class="label label-default">'.count($files).'</span></h3>';
$perpage = 1000;
if (isset($_GET['page'])) {
$i = $_GET['page']*$perpage;
$max = $i+$perpage;
}else{
$i=0;
$max = $perpage;
}
if ($max>count($files)) {
$max=count($files);
}
for ($i; $i<$max; $i++)
{
$num = $files[$i];
$title = str_replace($folder.'/', '', $num);
echo '
<div class="col-sm-6 col-md-3">
<div class="thumbnail">
<img src="'.$num.'" alt="...">
<div class="caption">
<p>...</p>
</div>
</div>
</div>';
}
echo '<div style="clear:both;"></div>';
//Page
$p = round(count($files)/$perpage);
echo '
<nav>
<ul class="pagination">';
for ($i=0; $i < $p; $i++) {
$page = $i+1;
if ( isset($_GET['page']) && ($_GET['page']==$i) ) {
$class = ' class="active"';
}else{
$class = '';
}
echo '
<li'.$class.'>
<a href="?page='.$i.'">'.$page.'</a>
</li>';
}
echo '
</ul>
</nav>';
?>
</div>
</body>
</html>