Free Web Hosting Forum
(#1 (permalink))
Old
Member
tr_ellis1973@msn.com is on a distinguished road
 
Posts: 30
Join Date: Feb 2009
Location: DesMoines IA
Default database images - 04-30-2012, 06:17 PM

I am new to this. all I want to do is insert either an image or the path of the picture and have it be pulled up into the the web page. I have never done this before. I tried to upload the image into the database but that doesn't seem to work so would the path in the just pull up the picture. the database consists of the following rows.
Name
ingredients
instructions
category
Image.

What I want is to just display the image as the page loads so that It won't show the link.
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
ShocK's Avatar
Senior Member
ShocK is on a distinguished road
 
Posts: 4,063
Join Date: Jul 2011
Location: UK
Default 04-30-2012, 08:34 PM

You mean you just want a page with an image on it? So you go to a page and it's there?
Reply With Quote
(#3 (permalink))
Old
Mate's Avatar
Senior Member
Mate is on a distinguished road
 
Posts: 381
Join Date: Apr 2012
Location: Middle England
Default 04-30-2012, 08:52 PM

If you want to store your images within a MySQL database/table, use the data type BLOB.

There's a good tutorial here that might point you in the right direction.
Reply With Quote
(#4 (permalink))
Old
Member
tr_ellis1973@msn.com is on a distinguished road
 
Posts: 30
Join Date: Feb 2009
Location: DesMoines IA
Default 04-30-2012, 09:17 PM

I'm wanting to load everything into a database and pull everything throu sql queries. and bam the picture is showing.
Reply With Quote
(#5 (permalink))
Old
d3iti's Avatar
Super Moderator
d3iti is on a distinguished road
 
Posts: 6,481
Join Date: Jul 2009
Location: Spain
Default 05-01-2012, 07:36 AM

Hello,

I think it is not very suitable to save images in the database because you can overload the server database and your website may be suspended/canceled.

Is better than in the database you save the link to the image file. Then stored in a server folder the image files.

It's just an opinion.


Recuerda realizar copias de seguridad de tus sitios web. Si este mensaje te ayudó puedes pulsar sobre el botón karma
Reply With Quote
(#6 (permalink))
Old
Member
tr_ellis1973@msn.com is on a distinguished road
 
Posts: 30
Join Date: Feb 2009
Location: DesMoines IA
Default 05-01-2012, 12:32 PM

then with that then would i save the link in the database or on the web page itself? cause what i'm doing is a drink recipe website.
Reply With Quote
(#7 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 732
Join Date: Dec 2010
Default 05-01-2012, 01:17 PM

You can save the path for images. For example, in case photo_l.jpg is in images folder in public_html
directory, the path saved in DB table would be--images/photo_l.jpg.
To call the image path, you need to make a query similar to below:

$query = "select * from table_name where Name='$name'";
$result= mysql_query($query);
$row = mysql_fetch)_array($result);

For displaying images, you can use <img> tag as shown below:

<img src="<?=$row['image']?>" width="100" height="120" border="0">

Last edited by grace1004; 05-02-2012 at 12:05 AM.
Reply With Quote
(#8 (permalink))
Old
Member
tr_ellis1973@msn.com is on a distinguished road
 
Posts: 30
Join Date: Feb 2009
Location: DesMoines IA
Default 05-01-2012, 07:13 PM

can I put a path in the database then pull it up that way like say a row called pic with images/maritinglass.jpg?
Reply With Quote
(#9 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 732
Join Date: Dec 2010
Default 05-01-2012, 10:57 PM

The following example shows a table structure in my database:



At the top, the table name is displayed as--Table: guestbook. If you click 'Structure' tab,
you can see the table structure. My 'guestbook' table consists of 4 fields or columns--comm_id,
name, comment and datetime. So, what you are saying 'a row called pic', means actually a field
or column called pic.

In my case, $row = mysql_fetch_array($result)--means one line of data expressed in an array having
4 elements (fields).

Quote:
the database consists of the following rows.
Name
ingredients
instructions
category
Image.
The above shows your table schema. Here, $row['Image'] is the field (an element of the array), where
the image path to be saved. So, you can save the path in 'Image' field as images/maritinglass.jpg.

Added later:

You can save the image path by making an update query similar to below:

$query = "update table_name set Image = 'images/maritinglass.jpg' where Name='$name'";
mysql_query($query);

Last edited by grace1004; 05-02-2012 at 12:04 AM.
Reply With Quote
(#10 (permalink))
Old
Member
tr_ellis1973@msn.com is on a distinguished road
 
Posts: 30
Join Date: Feb 2009
Location: DesMoines IA
Default 05-02-2012, 03:26 AM

then my next question. then my image or pic row still should be blob or should I change it to text. char, varchar or etc. or just keep it the same as blob?

cause what I have now is just one page where it pulls up all the data in the table on one single page and I just wanna make one single page.

Last edited by tr_ellis1973@msn.com; 05-02-2012 at 03:32 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

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 Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com