  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                คือผมต้องการ จอยตาราง 3 ตาราง ออกมาซึ่งใน ตาราง file_upload ตารางที่จอยมี member และ category 
ใน ตาราง file_upload ผมต้องการ ให้ ฟิว Fil_permission = 'pubic' และ 'private' ของ Mem_ID ตัวเอง ออกมาโชว์ และ Fil_permission = 'public' ของคนอื่นมาโชว์ด้วยครับ 
  
Code (PHP) 
<?php
session_start();
//ob_start();
include "conn.php";
$Mem_ID = $_SESSION['ses_user_id'];
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <title><?php echo $title_web; ?></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="css/style.css" rel="stylesheet">
    </head>
    <body>
<div align = "center">
<img src="img/pic.gif" style = "width:150px;height:100px">
<img src="img/video.png" style = "width:150px;height:100px">
<img src="img/doc.png" style = "width:150px;height:100px">
</div>
    <!-- หมวดหมู่ -->
    <div align = "center">
          <input type="button" value="File ทั้งหมด" onClick="window.location='download.php';" style="width:150px;height:30px">
          <!--หมวดหมู่ รูปภาพ-->
          <input type="button" value="Picture" onClick="window.location='cat_pic.php';" style="width:150px;height:30px">
          <!--หมวดหมู่ วีดีโอ-->
          <input type="button" value="Video" onClick="window.location='cat_video.php';" style="width:150px;height:30px">
          <!--หมวดหมู่ เอกสาร-->
          <input type="button" value="Document" onClick="window.location='cat_doc.php';" style="width:150px;height:30px">
          <!--ไม่มีหมวดหมู่-->
          <input type="button" value="ไม่มีหมวดหมู่" onClick="window.location='cat_none.php';" style="width:150px;height:30px">
    </div>
    <br> 
    <hr>
    <br>
    <div align = "center">
    <form name="frmSearch" method="post" action="download.php">
    <table width="599" border="1">
    <tr>
      <th>Select 
        <select name="select" id="select">
          <option value="">- Select -</option>
          <option value="Fil_File" <?php if($_POST["select"]=="Fil_File"){echo"select";}?>>ชื่อไฟล์</option>
          <option value="Cat_Name" <?php if($_POST["select"]=="Cat_Name"){echo"select";}?>>หมวดหมู่</option>
          <option value="Mem_Name" <?php if($_POST["select"]=="Mem_Name"){echo"select";}?>>ชื่อผู้อับโหลด</option>
          <option value="Fil_DateCreate" <?php if($_POST["select"]=="Fil_DateCreate"){echo"select";}?>>วันที่-เวลอับโหลด</option>
          <option value="Fil_Expire" <?php if($_POST["select"]=="Fil_Expire"){echo"select";}?>>วันหมดอายุไฟล์</option>
        </select>
        Keyword
        <input name="search" type="text" id="search" placeholder = "กรอกข้อมูลที่ต้องการค้นหา" value="<?php echo $_POST["search"];?>" required>
      <input type="submit" value="Search"></th>
    </tr>
  </table>
      <!-- <input name="search" type="text" placeholder = "กรุณากรอกไฟล์ที่ต้องการ" required style="width:300px;height:30px">
      <input type="submit" value="Search" style="width:150px;height:30px"> -->
  </form>
  </div>
  <br>
        <?php
        //$sql = "select * from file_upload f ,member m , category c where f.Cat_ID = c.Cat_ID and f.Mem_ID = m.Mem_ID and f.Fil_Permission = 'Public' ";
        $sql = "SELECT * FROM file_upload f INNER JOIN member m ON f.Mem_ID = m.Mem_ID INNER JOIN category c ON f.Cat_ID = c.Cat_ID where f.Fil_Permission = 'Public' ";
        $query = mysqli_query($conn,$sql);
        
        // นับจำนวนข้อมูลที่ต้องการแสดง
        $Num_Rows = mysqli_num_rows($query);
        //แบ่งหน้า
          $Per_Page = 10;  //จำนวนหนึ่งหน้ามีกี่แถว
          $Page = $_GET["Page"];
          if(!$_GET["Page"])
          {
            $Page=1;
          }
          
          $Prev_Page = $Page-1;//ย้อนกลับ
          $Next_Page = $Page+1;//ไปต่อ
          
          $Page_Start = (($Per_Page*$Page)-$Per_Page);//จุดเริ่มต้นของหน้าถัดไป array
          if($Num_Rows<=$Per_Page)
          {
            $Num_Pages =1;
          }
          else if(($Num_Rows % $Per_Page)==0)
          {
            $Num_Pages =($Num_Rows/$Per_Page) ;
          }
          else
          {
            $Num_Pages =($Num_Rows/$Per_Page)+1;
            $Num_Pages = (int)$Num_Pages;
          }
        //search
        if($_POST["select"] != "" and  $_POST["search"]  != '')
        {
            $sql .= " AND (".$_POST["select"]." LIKE '%".$_POST["search"]."%' ) ";
        }
        else if($_POST["select"] == "" and  $_POST["search"]  != '')
        {
          $sql .= " and Mem_Name LIKE '%".$_POST["search"]."%' or Fil_File LIKE '%".$_POST["search"]."%' or Cat_Name LIKE '%".$_POST["search"]."%' ";
        }
        $sql .= "order by Fil_ID desc LIMIT $Page_Start , $Per_Page";
        
        //****************************************************
        $query = mysqli_query($conn,$sql);
        
        // ตรวจสอบผลการค้นหาข้อมูล
        // if( $Num_Rows == 0 ) 
        //   { 
        //     echo '<script>alert( "ไม่พบข้อมูลที่ต้องการค้นหา" ); window.location = "index.php";</script>'; die(); 
        //   }
        ?>
        <div align="center"><h1>Download File</h1></div>
      <table border="1" align="center">
          <tr>
              <th>No.</th>
              <th>File Name</th>
              <th>Category</th>
              <th>By</th>
              <th>Date</th>
              <th>File Expire</th>
              <th>Download</th>
          </tr>
          <?php
          $n = 1;
          while ($result = mysqli_fetch_assoc($query))
          {
            ?>
            <tr>
              <td> <?php echo $n++; ?> </td>
              <td> <?php echo substr($result['Fil_File'], strpos($result['Fil_File'], '/')+1 ); /*หาตำแหน่ง/ แล้ว+1 และเอาตั้งแต่ตำแหน่งนั้นแล้วเริ่มเอาตำแหน่งที่2*/?> </td>
              <td> <?php echo $result['Cat_Name']; ?> </td>
              <td> <?php echo $result['Mem_Name']; ?> </td>
              <td> <?php echo $result['Fil_DateCreate']; ?> </td>
              <td> <?php echo $result['Fil_Expire']; ?> </td>
              <td> <input type="button" value="Download" onclick="window.location ='download_file.php?file=<?php echo $result['Fil_Link'];?>' "></td>
            </tr>
          <?php
          }
          ?>
      </table>
    <br>
    <div align="center"> Total <?php echo $Num_Rows;?> Record : <?php echo $Num_Pages;?> Page :
    <?php
      if($Prev_Page)
      {
        echo " <a href='download.php?Page=$Prev_Page'><< Back</a> ";
      }
      for($i=1; $i<=$Num_Pages; $i++)
      {
        if($i != $Page)
        {
          echo "[ <a href='download.php?Page=$i'>$i</a> ]";
        }
        else
        {
          echo "<b> $i </b>";
        }
      }
      if($Page!=$Num_Pages)
      {
        echo " <a href ='download.php?Page=$Next_Page'>Next>></a> ";
      }
      
    ?>
    </div>
    <br>
    <div align="center">
    <input type="button" value="<< Back Home" onClick = "window.location ='index.php'">
    </div>
    </body>
</html>
 
 
  Tag : HTML5, JavaScript, Apache, Windows               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2018-05-16 02:38:40 | 
                      By :
                          lemon29 | 
                      View :
                          883 | 
                      Reply :
                          1 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  |