Forum Moderators: coopster
I am still a newbie so I need teaspoons... Here is the script:
<?php
include('db_connection.php');
$sConn = mysql_connect($dbServer, $dbUser, $dbPass)
or die("Couldn't connect to database server");
$dConn = mysql_select_db($file_database, $sConn)
or die("Couldn't connect to database $dbDatabase");
$dbQuery = "SELECT blobId, blobTitle, blobType ";
$dbQuery .= "FROM myBlobs WHERE blob_cat=3 ";
$dbQuery .= "ORDER BY blobTitle ASC";
$result = mysql_query($dbQuery) or die("Sorry, halted");
?>
<table border="1" width="100%">
<tr>
<td width="34%" bgcolor="#FF9900"><b>Description</b></td>
<td width="33%" bgcolor="#FF9900"><b>Type</b></td>
<td width="33%" bgcolor="#FF9900"><b>File</b></td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td width="34%"><?php echo $row["blobTitle"];?></td>
<td width="33%"><?php echo $row["blobType"];?></td>
<td width="33%"><a href="download.php?fileId=<?php echo $row["blobId"];?>">Download file</a></font>
</td>
</tr>
<?php
}
echo "</table>";
?>
1. have a switch statement to recognise what the mime type is, then based on that result show a different image.
switch ($row["blobType"]){
case "application/zip":
$myImage = "zip.gif";
break;
case "image/jpg":
$myImage = "jpeg.gif";
break;
}
<img src="<?php echo $myImage;?>">
2. have the user choose from a drop down what order they want, and then rewrite you SQL query accordingly.
$order = $_POST["order"];
$query = "SELECT * FROM myTable ORDER BY row1 $order";
Ally
[edited by: Scally_Ally at 1:44 pm (utc) on June 1, 2007]