Anyone know how to display a picture or anything else in your webpage after getting it from a mySQL DB? Google helped me to run into this tutorial: http://www.php-mysql-tutorial.com/php-mysql-upload.php
for being able to download files from a mysql DB, but I can;t figure out how to show them.
I've got a few sound files that are actually flash files, .SWF. I'm storing them in my DB and am trying to figure out how to grab one of the .swf files from the DB and display it in my page. This is the code I have so far. It does grab the file from the DB but when I go to display it I get garbage: its printing the file contents and not actaully using the file as it should.
the html output and content must be sent in seperate streams. This requires a seperate database query and page request for each file you want to display.
Whoa, you lost me there. I have no idea what you mean by seperate streams!
I understand that for each item I wish to display, I'll need to make another DB query to retrieve it. What do you mean by making a seperate page request?
But all deal with downloading, which doesn't help me. Can you point me to a site that gives a how-to or some further insight on how to display binary data or give me a bit more of an explanation?
Ok, so let me get this straight. Being able to get any file for download is actually part of the puzzle because the website will be requesting the file essentially has to download it.
So the PHP page that gets the file (get.php) kinda has it attached and would be something like this:
Bad-ass! Here's how the code ended up coming out for those interested. (I always hate it when someone asks a question, finds the answer and doesn;t post it!)
Thanks for pointing me in the right direction feyd.
<?PHP $query = "SELECT id FROM `Sound_Files` ORDER BY RAND() LIMIT 1";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_row($result);
$id = $row[0];
####################
# The Beef
####################
//This takes the random ID and gets the sound file associated with
//it. It should actually display/play the .swf file from the DB
?>
<html>
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<embed src="get.php?id=<?PHP echo $id; ?>" width="1" height="1"></embed>
</body>
</html>
The file responsible for getting the file out of the DB and returning it to the requested page:
I always wondered how sites like newegg.com display all their content. There's no doubt in my mind that they use someing very similar to the above to get all their images, details and such to dynamically build all those pages.