Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can do this in two steps.</p> <p>Create a PHP script that accepts a parameter to identify through a unique ID, which Row has the image to display. This script will extract the image from database and send the codes with appropriate mime-type, so that browser understands. This way, apply a class to the container (or body tag) and display the background like:</p> <pre><code>.backgroundTile { background-image: url('/path/to/php-image-render-script.php?image_id=1212') !important; background-repeat: repeat; } </code></pre> <p>Example PHP Script (Source- <a href="http://cookbooks.adobe.com/post_Display_an_image_stored_in_a_database__PHP_-16637.html" rel="nofollow">http://cookbooks.adobe.com/post_Display_an_image_stored_in_a_database_<em>PHP</em>-16637.html</a> ) :</p> <pre><code>&lt;?php require_once('Connections/testConn.php'); ?&gt; &lt;?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION &lt; 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; } } $colname_getImage = "-1"; if (isset($_GET['image_id'])) { $colname_getImage = $_GET['image_id']; } mysql_select_db($database_testConn, $testConn); $query_getImage = sprintf("SELECT mimetype, image FROM images WHERE image_id = %s", GetSQLValueString($colname_getImage, "int")); $getImage = mysql_query($query_getImage, $testConn) or die(mysql_error()); $row_getImage = mysql_fetch_assoc($getImage); $totalRows_getImage = mysql_num_rows($getImage); header('Content-type: ' . $row_getImage['mimetype']); echo $row_getImage['image']; mysql_free_result($getImage); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload