tags:

views:

89

answers:

2

How to store image location In MySQL?

+6  A: 

You would just store it in a varchar field, since the location is plain text. You would then use PHP to go grab the image at that locale, like so:

$res = mysql_query("select imgLocation from table where id = 1");
if ($res)
{
    $row = mysql_fetch_row($res);
    $imgLocation = $res[0];
    echo '<img src="' . $imgLocation . '" border=0 />';
}
Eric
+1  A: 

You would need to create a table in MySQL that would have a varchar column.

Then, in PHP, you would connect to the database using mysql_connect().

Next, you'd form your query (in the form of an INSERT statement). This would contain your column names and values that you are inserting into your database. Lastly, you call mysql_query() using your query statement as a parameter.

There is a bunch of documentation on the web about using mysql_connect, mysql_query, etc. That should get you started.

Polaris878