| Welcome to Webforumz.com. |
|
Mar 28th, 2008, 17:02
|
#1 (permalink)
|
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."
|
|
|
Mar 28th, 2008, 17:51
|
#2 (permalink)
|
|
Section Manager - WOTM Assistant Editor - LZ
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
|
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" />';
|
|
|
Mar 28th, 2008, 19:05
|
#3 (permalink)
|
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."
|
|
|
Mar 28th, 2008, 19:05
|
#4 (permalink)
|
|
Section Manager - WOTM Assistant Editor - LZ
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
|
Re: Database and images
Yeh that should be fine, it's what I'm using for my current project and it seems fine.
|
|
|
Mar 28th, 2008, 19:16
|
#5 (permalink)
|
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."
|
|
|
Mar 28th, 2008, 19:26
|
#6 (permalink)
|
|
Section Manager - WOTM Assistant Editor - LZ
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
|
Re: Database and images
Can I see your full code please?
|
|
|
Mar 28th, 2008, 19:31
|
#7 (permalink)
|
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"> </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;"> </div>
</div>
<div id="footer">Copyright © 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."
|
|
|
Mar 28th, 2008, 19:48
|
#8 (permalink)
|
|
Section Manager - WOTM Assistant Editor - LZ
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
|
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" />';
|
|
|
Mar 30th, 2008, 13:35
|
#9 (permalink)
|
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."
|
|
|
| Thread Tools |
|
|
| 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
HTML code is Off
|
|
|
|
|
|