hi , i am new to php.
i had a problem. whenever i upload a file it should get inserted in the database. it is working fine. now i should display that in a table in the browser but whenever i upload a file all other files names are not cuming only that file name,size,uploadeddate,uploadedby are displaying many times. if i upload another file now its details are displaying many times. can any one help me please......

<html>
<body>
<form enctype="multipart/form-data" action="upload2.php" method="POST">
<table>
<tr>
<td><img src="Logofinalcopy.gif"></td>
</tr>
</table>
<table>
<br><br>
<tr>
	<td>
		<strong>Please choose a file: </strong>
	</td> 
	<td>
		<input name="uploaded" type="file"><br>
    </td>
</tr>
<tr><td>
<input type="submit" value="upload"></td></tr>

</table></form></body></html>
<?php
ob_start();
@session_start();
require_once ("check.php");
$con=mysql_connect("10.70.1.50","invensis","invensis");
if(!$con)
    {
             die('Could not connect: ' . mysql_error());
    }
mysql_select_db("database_myproject",$con);
 $sql= "select * from files where uploadedby='$_SESSION[username]'";
 mysql_error();
    $result=mysql_query($sql);
    $num=mysql_num_rows($result);

?>
<html>
<body>
<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px">
<tr>
<th>filename</th>
<th>uploadedby</th>
<th>uploadeddate</th>
<th>size</th>
</tr>
 <?php
    $sno=1;
    while($rows=mysql_fetch_array($result)){    
    ?>
 <tr>
 
<td><?php echo $filename;?></td> 
<td><?php echo $username; ?></td>
<td><?php echo date("d-m-y");?></td>
<td><?php echo $size; ?> </td></tr>
<?php
    $sno=$sno+1;
}
?>

</table></body></html>

What are you uploading and where are the files stored. There is a major difference if the files are stored inside the database or in a directory on the server.
But even so, uploading is one thing, getting the uploaded file to show inside a web page is entirely different.. A simple plain text file is not to difficult but if you want do display a Word document or PDF or something like that.... can't remember when I have seen a site capable of doing that.
Displaying jpg, png or gif files (images that is), is not so hard to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.