使用MySQL和PHP存储图像位置

1 php mysql

如何在MySQL中存储图像位置?

Eri*_*ric 7

您只需将其存储在varchar字段中,因为该位置是纯文本.然后,您将使用PHP在该语言环境中获取图像,如下所示:

$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 />';
}
Run Code Online (Sandbox Code Playgroud)