Displaying files from database

Reply

Join Date: Oct 2009
Posts: 25
Reputation: SuntechWebsites is an unknown quantity at this point 
Solved Threads: 0
SuntechWebsites SuntechWebsites is offline Offline
Light Poster

Displaying files from database

 
0
  #1
31 Days Ago
Is there a way I can display an image, pdf or word doc that is stored in a my sql database?
I tried to pull up a word doc with this:
  1. $sql = " SELECT * FROM user WHERE username = '$_SESSION[MM_Username]' ";
  2. $result = mysql_query($sql);
  3. while($row=mysql_fetch_array($result)) {
  4. $inv=$row['invoice'];}
  5. ?>
  6. <?php echo " Your Invoice: ".$inv." ";
  7. ?>

But all I got was code from the document.
Last edited by Ezzaral; 31 Days Ago at 1:06 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,010
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 130
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster
 
-1
  #2
31 Days Ago
I take it that your invoice field just contains the file's url and not the file itself.

  1. $inv = $row['invoice'];
  2. $base = basename($inv); //you don't want to display the full path in the link label
  3.  
  4. ...in loop...
  5. echo "<a href=\"$inv\" title=\"\">$base</a>";
Last edited by ardav; 31 Days Ago at 12:21 pm.
Dunna letta dem afool ya - duh reppa sistema is da evil. INDETERMINACY is alive anda wella - force a duh issue.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 25
Reputation: SuntechWebsites is an unknown quantity at this point 
Solved Threads: 0
SuntechWebsites SuntechWebsites is offline Offline
Light Poster
 
0
  #3
31 Days Ago
No it is the file itself. Not a good idea?
My goal is to have it so the site owner can upload an invoice for a specific user. Then when that user loggs in, they will only be able to view their invoice or whatever via the session.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC