Tom
I am very new to this and easily confused! When you say a string like any other, my table fields at the moment are just integers etc. What I want to do is (I'm using MySQL Front) is put the link in as a new field - excuse me if I am not making sense. So, when the data is displayed it has with it an image alongside. How do I describe the field? There are a lot of descriptors which I do not recognise in MySQL Front!
imgurl varchar(256)
again you will have to figure it out for mysql front. I would imagine that it is very similar to adding an int field but you may have an option to change the col type?
the sql for altering an existing table in this instance would be something like:
ALTER TABLE tablename ADD COLUMN imgurl VARCHAR(256) AFTER somecolumn;
MySQL-Front is nothing but a GUI interface for MySQL. Everything that is true for MySQL will be true for MySQL-Front. You should absolutely download a copy of the mysql manual and read it. It might not make sense at first, but as you play around, you'll find it easier and easier.
jatar_k mentioned using
varchar(256)
If you don't understand what he's talking about, check out the manual, specifically
Chapter 3, Tutorial [mysql.com]
Chapter 6.2 on Column Types [mysql.com] especially 6.2.3 on strings
And you may want to read more about strings [mysql.com]
Good luck!
Tom
Works like a champ. We have all of images in a directory under the root called "images" so the the sting simple is "images/url of pic"
it's that simple. We also control the size of the image for viewing purposes here as well. We have a filed for width and size, so it's all automatic.
There's currently a thread on mysql, quotes and addslashes that you might want to read.
[webmasterworld.com...]
Tom
From what I have read so far I presume there is no way that Mysql can store images? I have been trying to fathom out "BLOB" and I have looked at MySql but am none the wiser for the moment.
Blob is a large chunk of data. One thing that sets it apart is that it can not have a default value, if it isn't inserted it is blank. It can be any size you like. Each individual blob record will be a different size. Each record takes up as much room as the data it stores needs.
I use blob fields for comments. I never know how verbose someone is going to be. They could write 10 words or 10 paragraphs. If I use blob I don't have to worry about the amount of data someone might try to put in. They really are a messy field type and certain functions ie. group by are difficult to use on them. I would recommend staying away from them except where completely necessary.
As with all DB structure you have to be very careful to know what kind of data you are going to be storing and make the appropriate choice of col type. DB design and architecture is a skill, I think, and people have a tendancy to not take quite as much time designing and jump right in. I don't program one character until I have gotten all relevant input from the client and drawn and redrawn my DB until I am completely happy with its functionality. Unlike php all my DB spends most of its time on paper and all I do is input the fields when the time comes to build it.
You don't even need a computer to design a database, I usually write out all the queries and then I can hand it to someone if need be.
You also have to keep in mind that DB design is very much akin to object oriented programming. Each table within your DB represents a particular object and you store each of it's different attributes within it. Your scripting language makes up it's methods. Once you understand what piece belongs with each object you then reference each one internally by giving it a primary key to make it unique and easily referenced. You then decide which are sub classes and which superclasses and there by can create your relationships so that your data has a logical flow.
All of the above keeps you from storing row upon row of redundant data, repeating fields in multiple tables and enables you to use the true power of a select statement.
At any rate I seem to have strayed a little from my original purpose in this post but there is a definite art to DB design and creation. I don't think enough people realize that a properly created and referenced DB can save you a lot of time and problems when it comes to programming the lang for getting this data out. People treat them too often like the hall closet where they can throw whatever they find in and don't mind sorting through apile of garbage to find what they need. They don't understand that it is a living entity that is the core of the whole project and if the base of your project is stunted then the rest can only hope to ever be stunted.
just my two cents
I have images and text being grabbed from my database but what I would like to achieve is the link to the data appearing in the same page each time. As my page appears there are say 20 pieces of data all with links to more information about the individual items of data. At the moment they link to 20 new pages which is a bit time consuming to update. The pages have the same overall appearance but with the new data appearing from the link on that page. So, I am trying to have one page with the ability to show 20 new pieces of data, one at a time depending on the link chosen (I hope this makes sense!)ie. a template type of page with the ability to nest different data from MySql within in it I'm sure there is an answer, I just need a pointer to get me started.