Web Design and Development Forums

Database and images

This is a discussion on "Database and images" within the MySQL section. This forum, and the thread "Database and images are both part of the Databases category.


Go Back   Webforumz.com > Databases > MySQL

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Mar 28th, 2008, 17:02   #1 (permalink)
 
acrikey's Avatar
 
Join Date: Mar 2007
Location: UK
Posts: 308
Database and images

I would like to store a image on a database of the customers last bill. Then when they click on the last bill link in my php script it displays the image from the database, does anyone know how I can do this?
__________________
"It is not how much you do, but how much love you put in the doing."
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 28th, 2008, 17:51   #2 (permalink)
Section Manager - WOTM
Assistant Editor - LZ
 
Jack Franklin's Avatar
 
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
Blog Entries: 5
Re: Database and images

Well you save the image to a location eg www.yoursite.com/bills/fred_blogs.jpg

In your database you store the URL.

Then call it like so:
PHP: Select all

(Get data from db and then)
echo 
'<img src="'.$imageURL.'" alt ="Bill" />'
__________________
Section Manager (WOTM)

My Weblog & E-Portfolio
Catch me daily on: Twitter | Digg | Flickr
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 28th, 2008, 19:05   #3 (permalink)
 
acrikey's Avatar
 
Join Date: Mar 2007
Location: UK
Posts: 308
Re: Database and images

it it set as a varchar?
__________________
"It is not how much you do, but how much love you put in the doing."
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 28th, 2008, 19:05   #4 (permalink)
Section Manager - WOTM
Assistant Editor - LZ
 
Jack Franklin's Avatar
 
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
Blog Entries: 5
Re: Database and images

Yeh that should be fine, it's what I'm using for my current project and it seems fine.
__________________
Section Manager (WOTM)

My Weblog & E-Portfolio
Catch me daily on: Twitter | Digg | Flickr
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 28th, 2008, 19:16   #5 (permalink)
 
acrikey's Avatar
 
Join Date: Mar 2007
Location: UK
Posts: 308
Re: Database and images

PHP: Select all

<?php
// Connects to my Database
mysql_connect("my host""myusername""mypassword") or die(mysql_error());
mysql_select_db("fieldworks") or die(mysql_error());
$data mysql_query("SELECT * FROM mytable")
or die(
mysql_error());

(
Get data from db and then)
echo 
'<img src="'.$imageURL.'" alt ="Bill" />'


?>
have made a row for the imageURL and it come back with a blank screen any suggestions?
__________________
"It is not how much you do, but how much love you put in the doing."
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 28th, 2008, 19:26   #6 (permalink)
Section Manager - WOTM
Assistant Editor - LZ
 
Jack Franklin's Avatar
 
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
Blog Entries: 5
Re: Database and images

Can I see your full code please?
__________________
Section Manager (WOTM)

My Weblog & E-Portfolio
Catch me daily on: Twitter | Digg | Flickr
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 28th, 2008, 19:31   #7 (permalink)
 
acrikey's Avatar
 
Join Date: Mar 2007
Location: UK
Posts: 308
Re: Database and images

Code: Select all
<head>
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
<title>Account Details</title>
</head>


<style type="text/css">
<!--
@import url("default.css");
<!--
body {
    background-repeat: repeat-x;
}

</style>
<body>
<div id="header">
<script>
var Digital=new Date()
var month=Digital.getMonth()
if (month <= 2){    // month is between jan and march    
    document.write("<IMG SRC='http://www.lightex.co.uk/fieldworks/images/img5.jpg'>");
} else if (month <= 5){
    // month is between april and june
    document.write("<IMG SRC='http://www.lightex.co.uk/fieldworks/images/img2.jpg'>");
} else if (month <= 8){    // july and september
    document.write("<IMG SRC='http://www.lightex.co.uk/fieldworks/images/img2.jpg'>");
} else {    // otherwise its between oct and dec
    document.write("<IMG SRC='http://www.lightex.co.uk/fieldworks/images/img3.jpg'>");
}
</script>
</div>
<div id="page">
  <div id="content">
        <div id="welcome" class="post">
            <h1 class="title">Last Bill</h1>
            <IMG SRC="http://www.lightex.co.uk/fieldworks/images/420 copy.png" width="131" height="106">
        <div class="content">
              <h3 align="center"><br />
              </h3>
                <h3 align="center">&nbsp;</h3>
          </div>
    </div>
        <div id="example" class="post">
            <?php
// Connects to my Database
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("fieldworks") or die(mysql_error());
$data = mysql_query("SELECT * FROM ")
or die(mysql_error());

(Get data from db and then)
echo '<img src="'.$imageURL.'" alt ="Bill" />'; 


?>
            <br>
            
            <div class="content">
                                  
              
          </div>
        </div>
  </div>
    <div id="sidebar">
        <div id="menu">
            <ul>
              <li><a href="homepage.html" onClick="logout_confirm(); return false;">Homepage</a>
             <script> function logout_confirm() {
  if(confirm("You are about to logout?"))
    window.location = "homepage.html";
}</script></li>
                <li><a href="login_success.php" title="">Login Homepage</a></li>
              <li><a href="fieldworks/accountdetails.php" title="">Account Detail</a></li>
                <li><a href="lastbill.php" title="">Last Bill</a></li>
                <li><a href="estatedetails.php" title="">Estate Details</a></li>
                <li><a href="fieldworks/contactuslogin.php" title="">Contact Us</a></li>
            </ul>
        </div>
        
        <div id="updates" class="boxed">
            <h2 class="title">Recent Updates</h2>
            <div class="content">
              <ul>
                <li> </li>
                <li>
                  <h3 class="style7">Coming Soon</h3>
                </li>
              </ul>
              <p>We will be extending our services to parks  and large lawns.</p>
              <ul>
                <li>
                  <h3></h3>
                </li>
              </ul>
          </div>
            <div class="content">
                <!-- Paste this code into the BODY section of your HTML document  -->


            </div>
      </div>
    </div>
    <div style="clear: both;">&nbsp;</div>
</div>
<div id="footer">Copyright &copy; 2008 filedworks.com. Designed by <a href="ttp://www.blanedesigns.com">Blane Designs</a>
  <p id="links"><br />
  <a href="#">Privacy Policy</a>
</div>
</body>
__________________
"It is not how much you do, but how much love you put in the doing."
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 28th, 2008, 19:48   #8 (permalink)
Section Manager - WOTM
Assistant Editor - LZ
 
Jack Franklin's Avatar
 
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
Blog Entries: 5
Re: Database and images

Ok.
PHP: Select all

mysql_connect("""""") or die(mysql_error());
mysql_select_db("fieldworks") or die(mysql_error());
$data mysql_query("SELECT * FROM ")
or die(
mysql_error());

(
Get data from db and then
You need to create an array and go through one by one using 'while...'
echo '<img src="'.$imageURL.'" alt ="Bill" />';
__________________
Section Manager (WOTM)

My Weblog & E-Portfolio
Catch me daily on: Twitter | Digg | Flickr
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Mar 30th, 2008, 13:35   #9 (permalink)
 
acrikey's Avatar
 
Join Date: Mar 2007
Location: UK
Posts: 308
Re: Database and images

what sort of array does it need to be?
__________________
"It is not how much you do, but how much love you put in the doing."
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with my Servlet - retrieving images from database Love2Java Java, JSP, Cold Fusion 1 Dec 19th, 2007 13:20
Database? SpickenSpanDesign PHP Forum 18 Dec 12th, 2006 19:07
upload images in database and folder manzil PHP Forum 1 Aug 11th, 2006 16:06
XML Code for transfering data from one SQL Server Database to another database plolla XML, RSS & Atom 1 Aug 3rd, 2006 18:37



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 09:20.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59