Problem getting and image to display with link in Database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
KSL
Forum Newbie
Posts: 5
Joined: Thu May 01, 2008 6:39 am

Problem getting and image to display with link in Database

Post by KSL »

Hi im very new to PHP and MYSQL,

I have build the website http://www.key-services.co.uk and on that site we have residential propertys listed over 5+ pages just as images and text.

I am now trying to set up all of the propertys in a database so they appear just as they do now, but it can be sorted by property price and have the option for the user to sort by other means.

Now as i said i am very new and so am just guessing my way through most of it.

I am using a book called php and MySql for Dummies and it has helped a little but i am having problems with the images.

In the book it states that if you want to have the record show an image then all you need to do it put the path of where the image is stored in a 'Char' field and it will display, now as i am sure you have guessed i am here because that is not working, all it is doing is displaying the Image Path as text.

I am testing this on a page in my website and this can be viewed by going to
http://www.key-services.co.uk/Cyprus_Re ... ttings.php?

The Table structure is below (this is pasted from my MySql manager and so is not the actual code but just info on how the fields are set up. the image location is

ResID char(3)
Type varchar(15)
Name varchar(100)
Desc text
Pic1 varchar(15)
Pic2 varchar(15)
Pic3 varchar(15)
Euro Price decimal(10,2)
CYP Price decimal(10,2)
:

(please remember i am a total Newb at this so Dumbed down language would be preffered)

Thank you in advance for any help received,

Gemma
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Problem getting and image to display with link in Database

Post by califdon »

You're probably new to HTML, as well. In order to display an image (under any circumstances), you must use an HTML <IMG ...> tag, with the SRC= property set to the URL of the image you want displayed. So, where your page source now shows:

Code: Select all

 
<td>Firework images/Holiday Thumbs/Coral Bay Thumb.jpg</td>
...it must look like this:

Code: Select all

<td><img src="Firework images/Holiday Thumbs/Coral Bay Thumb.jpg"></td>
I would strongly suggest that you reconsider naming your folders and files with spaces in them. It will cause you lots and lots of problems.

I don't know what software you used to generate this page (which is generally attractive), but the page it generates has TONS of nonfunctional code in it. That will slow down the loading of the page.
KSL
Forum Newbie
Posts: 5
Joined: Thu May 01, 2008 6:39 am

Re: Problem getting and image to display with link in Database

Post by KSL »

Thanks for your Response, Worked a Treat.

I am self taught as my only experience is with basic VB programming, so i have had to rely on code that is automatically generated by my HTML editor (Dreamweaver MX when i started building the site and i have just upgrades to Dreamweaver CS3). So i am Guessing that is where most of the extra code has come from, i have heard before that it dumps a load of usless code in but i do not know which part of the code is useless so i dare not deleate anything. If you have any advice on this i would again be very grateful. I will also start to rename those folders now.

Thanks again for this help, its guys like you of forums like this that have stopped me from collapsing in a heap on the floor in a fit of madness :banghead: on a good number of occasions.

Gemma

califdon wrote:You're probably new to HTML, as well. In order to display an image (under any circumstances), you must use an HTML <IMG ...> tag, with the SRC= property set to the URL of the image you want displayed. So, where your page source now shows:

Code: Select all

 
<td>Firework images/Holiday Thumbs/Coral Bay Thumb.jpg</td>
...it must look like this:

Code: Select all

<td><img src="Firework images/Holiday Thumbs/Coral Bay Thumb.jpg"></td>
I would strongly suggest that you reconsider naming your folders and files with spaces in them. It will cause you lots and lots of problems.

I don't know what software you used to generate this page (which is generally attractive), but the page it generates has TONS of nonfunctional code in it. That will slow down the loading of the page.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Problem getting and image to display with link in Database

Post by califdon »

Yes, that's certainly why there is so much excess code in your script. WYSIWYG code generators are very useful, especially when used by experienced designers, and they unquestionably produce sharp looking web pages, but I never use them, partly because I learned HTML and scripting languages before there were WYSIWYG products; partly because I'm lazy and don't want to learn new software; and partly because I'm cheap and don't like to pay money for what I can do myself! :D It is also significant that I don't do web design as a profession, so productivity is not important to me. I'm retired and do pro bono work for nonprofits and as a hobby. Also, there are many things that WYSIWYG software simply cannot do, but I can write custom code to do. Try generating this page with Dreamweaver! And finally, I'm one of those nerds who actually enjoys programming and I would feel cheated if I let a program write the code for me! True.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Problem getting and image to display with link in Database

Post by Benjamin »

I'd recommend that you urlencode() your image strings.
Post Reply