Hello everyone, am writting a project displaying image from msql database through a search engine build with php, ajax - but the image is not displaying properly.
Please can any help me and i promise i will be grateful.
//Database
-- phpMyAdmin SQL Dump
--
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 29, 2012 at 02:20 AM
-- Server version: 5.5.24
-- PHP Version: 5.4.3
--
-- Database: `sii`
--
-- --------------------------------------------------------
CREATE DATABASE `sii`;
//Creating table
-- phpMyAdmin SQL Dump
--
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 29, 2012 at 02:20 AM
-- Server version: 5.5.24
-- PHP Version: 5.4.3
--
-- Database: `sii`
--
-- --------------------------------------------------------
--
-- Table structure for table `check_records`
--
CREATE TABLE `check_records` (
`id` int(10) NOT NULL auto_increment,
`name` varchar(200) default NULL,
`check_in_no` int(10) default '0',
`check_out_no` int(10) default NULL,
`check_date` date default NULL,
`image` blob NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=68 ;
INSERT INTO `click_records` VALUES (1, 'acting', '57', '1', 1, '77', '2007-07-31');
INSERT INTO `click_records` VALUES (2, 'art', '57', '1', 1, '37', '2007-07-31');
INSERT INTO `click_records` VALUES (3, 'art', '57', '1', 1, '18', '2007-09-22');
INSERT INTO `click_records` VALUES (4, 'acting', '57', '1', 1, '43', '2007-09-21');
INSERT INTO `click_records` VALUES (5, 'art', '57', '1', 1, '25', '2007-07-31');
INSERT INTO `click_records` VALUES (6, 'out', '51', '11', 52, '18', '2007-09-27');
INSERT INTO `click_records` VALUES (7, 'out', '51', '11', 52, '98', '2007-09-27');
INSERT INTO `click_records` VALUES (8, 'out', '51', '11', 52, '68', '2007-09-27');
INSERT INTO `click_records` VALUES (9, 'out', '51', '11', 52, '12', '2007-09-27');
INSERT INTO `click_records` VALUES (10, 'are', '51', '11', 52, '19', '2007-09-27');
//ajax.js
subject_id = '';
function handleHttpResponse() {
if (http.readyState == 4) {
if (subject_id != '') {
document.getElementById(subject_id).innerHTML = http.responseText;
}
}
}
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
//connection.php
<?php
$conn = mysql_connect("localhost","root","") or die("could not connect to server");
mysql_select_db("sii",$conn) or die("could not connect to database");
?>
//my search page
<html>
<head>
<title>search</title>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
function getScriptPage(div_id,content_id,get_count)
{
subject_id = div_id;
content = document.getElementById(content_id).value;
http.open("GET", "script_page.php?content=" + escape(content)+"&count="+get_count, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
</script>
</head>
<body>
<div class="ajax-div">
<div class="input-div"><b>
Enter Search Name here :
</b><input type="text" id="text_content" size="40" onkeyup="getScriptPage('count_display','text_content','1')">
<input type="button" class="button" value="Search" onmouseup="getScriptPage('output_div','text_content','0')">
<div id="count_display">
</div>
</div>
<div class="output-div-container">
<div id="output_div">
</div>
</div>
</form>
</div>
</body>
</html>
//script_page.php
<?php
include('conn.php');
$strlen = strlen($_GET['content']);
$display_count = $_GET['count'];
$select = "select * from check_records where name like '%".$_GET['content']."%'";
$res = mysql_query($select);
$rec_count = mysql_num_rows($res);
if($display_count)
{
echo "There are <font color='red' size='3'>".$rec_count."</font> matching records found.Click Search to view result(s).";
}
else
{
?>
<center>
<table class="sofT" cellspacing="0" border="1">
<tr>
<td colspan="5" class="phed" align="center"><font color='blue' size='3'>Search Result(s)</font></td>
</tr>
<tr>
<td class='phed'>Id</td>
<td class='phed'>Name</td>
<td class='phed'>Check_In_No.</td>
<td class='phed'>Check_Out_No.</td>
<td class='phed'>Date</td>
<td class='phed'>Image</td>
</tr>
<?php
if($rec_count > 0)
{
while($data=mysql_fetch_array($res))
{
echo "<tr>
<td class='sup'>".$data['id']."</td>
<td class='sup'>".$data['name']."</td>
<td class='sup'>".$data['check_in_no']."</td>
<td class='sup'>".$data['check_out_no']."</td>
<td class='sup'>".$data['check_date']."</td>
<td class='sup'>".$data['image']."</td>
</tr>";
}
}
else
echo '<td colspan="5" align="center"><FONT SIZE="2" COLOR="red">No matching name found....!</FONT></td>';
}
?>
</center>
// This is how the image is displaying>>>>
Register and join over 40,000 other developers!
Recent Topics
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
-
Job Gig PHP Form Needed
PJohnson - Apr 18 2019 03:55 AM
-
How to make code run differently depending on the platform it is running on?
xarzu - Apr 05 2019 09:17 AM
-
How do I set a breakpoint in an attached process in visual studio
xarzu - Apr 04 2019 11:47 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

Displaying image from msql database with search engine writting in php and ajax
Started by Samasi, Sep 02 2012 01:23 AM
Image Displaying error innerHTML ajax
No replies to this topic
#1
Posted 02 September 2012 - 01:23 AM
Also tagged with one or more of these keywords: Image Displaying error, innerHTML, ajax
Language Forums →
Other Languages →
ASP, ASP.NET and Coldfusion →
Dynamic controls and asp:button postbackStarted by Tchpowdog, 12 Jun 2016 ![]() |
|
![]() |
||
Language Forums →
HTML, CSS and Javascript →
Redirect after successful data post in AjaxStarted by PuddingEatsPanda, 16 Feb 2016 ![]() |
|
![]() |
||
Language Forums →
HTML, CSS and Javascript →
posting ajax form to multiple urlStarted by mutago, 16 Aug 2015 ![]() |
|
![]() |
||
![]() Call to script via ajax $.post fails unless followed by alert()Started by sayitblue, 11 Jul 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
Updating chart.js in ajax doesn't render the graph properlyStarted by sachinsharma1507, 03 Jun 2015 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download