如何使用链接从数据库中检索图像?

时间:2017-09-24 07:13:03

标签: javascript php html

我制作了一个页面,将图像保存为一个小小的blob。

现在我想通过鼠标在文本"图片"上从网页中检索它。

当我将鼠标悬停在文字上时#34;图片"它应该告诉我图片。

//here is my first page which save the image
<< ? php require_once('../../Connections/pictureinsertion.php'); ? >
<< ? php
if (!function_exists("GetSQLValueString")) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
    $theNotDefinedValue = "") {
    if (PHP_VERSION < 6) {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue = function_exists("mysql_real_escape_string") ?
      mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

    switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'".$theValue.
      "'": "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'".$theValue.
      "'": "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
    }
    return $theValue;
  }
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction. = "?".htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "picturfname")) {
  $insertSQL = sprintf("INSERT INTO pictures (photo) VALUES (%s)",
    GetSQLValueString($_POST['image'], "double"));

  mysql_select_db($database_pictureinsertion, $pictureinsertion);
  $Result1 = mysql_query($insertSQL, $pictureinsertion) or die(mysql_error());
}

mysql_select_db($database_pictureinsertion, $pictureinsertion);
$query_pictureinsertion = "SELECT * FROM pictures";
$pictureinsertion = mysql_query($query_pictureinsertion, $pictureinsertion) or die(
  mysql_error());
$row_pictureinsertion = mysql_fetch_assoc($pictureinsertion);
$totalRows_pictureinsertion = mysql_num_rows($pictureinsertion); ?
>
<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="pictureform" name="picturfname" method="POST" action="<?php echo $editFormAction; ?>">

<input type="file" name="image"/>
<br/>
<input type="submit" />
<input type="hidden" name="MM_insert" value="picturfname" />
</form>

<body>
</body>
</html>
<?php
mysql_free_result($pictureinsertion);
?>

0 个答案:

没有答案
相关问题