|
|
|
ช่วยเข้ามาดูหน่อยครับ เรื่่องการให้แสดงข้อมูลของ User นั้นๆ ที่ Login เข้ามา |
|
|
|
|
|
|
|
คือ ตอนผมเลือกส่งไฟล์เนี่ย ผมระบุผู้รับได้ แต่ตอนไปดูที่หน้าแสดงไฟล์อ่ะครับ ผมอยากให้แสดงเฉพาะ ไฟล์ที่ เราได้รับเท่านั้น ไม่เอาไฟล์ทั้งหมด
ประมาณนี่น่ะครับ
viewfiles.php
<?
session_start();
if($_SESSION['UserID'] == "")
{
echo "Please Login!";
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style_uploadfile.css" type="text/css" />
<title>Untitled Document</title>
<script language="javascript">
function js_popup(theURL,width,height) { //v2.0
leftpos = (screen.availWidth - width) / 2;
toppos = (screen.availHeight - height) / 2;
window.open(theURL, "viewdetails","width=" + width + ",height=" + height + ",left=" + leftpos + ",top=" + toppos);
}
</script>
</head>
<body>
<div id="Form">
<div id="header">
</div>
<h1>.::Upload files::.</h1>
<ul id="menu">
<li><a href="index.php?page=UploadFiles"><img src="images/upload.png" /> Upload Files</a></li></td>
<li><a href="ViewFiles.php"><img src="images/list.png" /> View Files</a></li>
<li><a href="index.php?page=Search"><img src="images/search.png" /> Search</a></li>
<li><a href="index.php?page=Profile"><img src="images/profile.png" /> Profile</a></li>
<li><a href="index.php?page=ChangePassword"><img src="images/change.png" /> Change Password</a></li>
<li><a href="#"><img src="images/manual.gif" /> Manual</a></li>
<li><a href="Logout.php"><img src="images/logout.png" /> Logout</a></li>
</ul>
</div>
<table width="68%" border="0" align="center" cellspacing="1" >
<tr>
<td>
<?
$objConnect = mysql_connect("localhost","root","6845") or die("Error Connect to Database");
$objDB = mysql_select_db("dc");
mysql_query("SET NAMES UTF8");
$strSQL = "SELECT * FROM files ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 15; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
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;
}
$strSQL .=" order by FilesID desc LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="100%" align="center" cellpadding="0" cellspacing="3" class="table">
<tr>
<td colspan="3" style="white-space:normal"><strong><img src="images/formupload.png" align="absmiddle"/> View Files</strong></td>
</tr>
<tr>
<td width="5%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>No.</strong></div></td>
<td width="10%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>File</strong></div></td>
<td width="15%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>Name</strong></div></td>
<td width="10%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>Day</strong></div></td>
<td width="15%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>Time</strong></div></td>
<td width="20%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>By</strong></div></td>
<td width="10%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>Details</strong></div></td>
<td width="10%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>ผู้รับ</strong></div></td>
<td width="10%" class="tbl5" style="white-space: nowrap;"><div align="center"><strong>Status</strong></div></td>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr >
<td class="tbl5"><div align="center"><?=$objResult["FilesID"];?></div></td>
<td class="tbl5"><center>
<?php
$file = $objResult["Filesname"];
$extension = strrchr( $file , '.' );
switch( $extension )
{
case '.jpg':
echo "<img src='images/icon/JPEG-Image-icon.png' />";
break;
case '.pdf':
echo "<img src='images/icon/pdf-icon.png' />";
break;
case '.png':
echo "<img src='images/icon/PNG-Image-icon.png' />";
break;
case '.gif':
echo "<img src='images/icon/GIF-Image-icon.png' />";
break;
case '.doc':
echo "<img src='images/icon/Office-Word-icon.png' />";
break;
case '.docx':
echo "<img src='images/icon/Office-Word-icon.png' />";
break;
case '.xls':
echo "<img src='images/icon/Office-Excel-icon.png' />";
break;
case '.zip':
echo "<img src='images/icon/rar-2.png' />";
break;
case '.rar':
echo "<img src='images/icon/rar-2.png' />";
break;
case '.txt':
echo "<img src='images/icon/TEXT-Image-icon.png' />";
break;
default :
echo 'นามสกุลของไฟล์ไม่อยู่ในรายการตรวจสอบ';
}
?>
</center></td>
<td class="tbl5"><center><?=$objResult["Name"];?></center></td>
<td class="tbl5"><center><?=$objResult["Date"];?></center></td>
<td class="tbl5"><center><?=$objResult["Time"];?></center></td>
<td class="tbl5"><center><a href="viewmember.php?UserID= <?=$objResult["UserID"];?>" onClick="js_popup('viewmember.php?UserID= <?=$objResult["UserID"];?>',783,600); return false;" title="Member"><?=$objResult["Name_M"];?></a></center></td>
<td class="tbl5"><center><a href="viewdetails.php?FilesID=<?=$objResult["FilesID"];?>" onClick="js_popup('viewdetails.php?FilesID=<?=$objResult["FilesID"];?>',783,600); return false;" title="">Details</a></center></td>
<td class="tbl5"><center><?=$objResult["Name_R"];?></center></td>
<td class="tbl5"><center><?=$objResult["Status"];?></center></td>
</tr>
<?
}
?>
</table>
<br>
<div class="table" align="center"> Total <?= $Num_Rows;?> Files <?=$Num_Pages;?> Page :</div>
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
mysql_close($objConnect);
?>
</td>
</tr>
</table>
</body>
</html>
ผมอยากได้ประมาณนี้ครับ เช่น ตอนนี้ผม Login เป็น admin ให้แสดงเฉพาะ ไฟล์ที่ถูกส่งถึง admin
แล้วนี้เป็น ฐานข้อมูลครับ
ช่วยหน่อยน่ะครับ แนะนำหน่อยครับ
Tag : PHP, MySQL, HTML/CSS
|
ประวัติการแก้ไข 2012-08-20 09:46:51
|
|
|
|
|
Date :
2012-08-20 09:44:59 |
By :
cappuczino |
View :
1095 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รูปภาพสุดท้าย ไม่ขึ้นครับ
เอา user id ที่ login มา where ใน sql ก็ได้นะครับ
Code (PHP)
$sql="SELECT * FROM files WHERE UserID ='".$_SESSION['UserID']."'";
|
|
|
|
|
Date :
2012-08-20 09:52:41 |
By :
nontadech |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sess_uid = $_SESSION['UserID'];
$strSQL = "SELECT * FROM files WHERE Name_R='$sess_uid'";
|
|
|
|
|
Date :
2012-08-20 09:53:42 |
By :
adaaugusta |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|