0
로그인 한 사용자가 추가 한 파일을 표시하는 데 문제가 있습니다. 변수를 SQL 쿼리에 올바르게 전달하는 방법을 모르겠습니다. 아무도 도와 줄 수 있습니까?PHP에서 sql을 사용하여 세션 변수를 사용하는 방법
현재 코드는 다음과 같습니다
<?php
include_once 'dbconnect.php';
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>File Uploading With PHP and MySql</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
<label>File Uploading With PHP and MySql</label>
</div>
<div id="body">
<table width="80%" border="1">
<tr>
<th colspan="4">your uploads...<label><a href="index.php">upload new files...</a></label></th>
</tr>
<tr>
<td>File Name</td>
<td>File Type</td>
<td>File Size(KB)</td>
<td>View</td>
</tr>
<?php
$sql="SELECT * FROM files";
$result_set=mysql_query($sql);
while($row=mysql_fetch_array($result_set))
{
?>
<tr>
<td><?php echo $row['file'] ?></td>
<td><?php echo $row['type'] ?></td>
<td><?php echo $row['size'] ?></td>
<td><a href="uploads/<?php echo $row['file'] ?>" target="_blank">view file</a></td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>
나는이 레코드 변경하려고 :
$sql="SELECT * FROM files";
$sql="SELECT file, type, size FROM files WHERE userId ='$_SESSION[userId]'";
mysql은 더 이상 사용되지 않으며 대신 mysqli를 사용하십시오. –
무슨 뜻인지 구체적으로 말씀해 주시겠습니까? – martyniuk
https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php –