473,473 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

multi image print

tolkienarda
316 Contributor
Hi all

below is a function that works to print out one image and my attempt to duplicate it in such a way that i can print multiple images the echo statement is in a loop and i don't know what the header("...") stuff is for but it was in the function is stole this code from

[PHP]
if ($_REQUEST[gim] == 1) {
header("Content-type: image/jpeg"); //don't know what this does
print $bytes; // bytes has the imgdata from one image stored in it
exit ();
}

//and in the body of the page

<img src=?gim=1 width=144>
[/PHP]

and here is my attempt this is in a loop
[PHP]

echo '<img src=" 'header("Content-type: image/jpeg"); $row[imgdata];' " '>

[/PHP]

thanks for input

eric
Feb 16 '07 #1
15 1536
Motoma
3,237 Recognized Expert Specialist
[PHP]

echo '<img src=" 'header("Content-type: image/jpeg"); $row[imgdata];' " '>

[/PHP]

thanks for input

eric
NOPE.

What the first script is doing, rather than returning text in the form of HTML, it is returning binary data in the form of a JPEG image.

That means when you view the php file, and save it, you are saving an Image, rather than a web page.

It is not possible to embed things the way you are trying to.
Feb 16 '07 #2
tolkienarda
316 Contributor
ok do you know a good way to display images out of a mysql database. i have done next to nothing with file storage in databases. with the exception of the project i am working on now i have alwasys just done text.

eric
Feb 16 '07 #3
Motoma
3,237 Recognized Expert Specialist
1. Make a PHP script that, when given an image ID via $_GET, displays an image from the database.

2. Make a PHP script that prints <img src=...> tags, each one referencing the PHP script above.
Feb 16 '07 #4
tolkienarda
316 Contributor
ok i will make those and post the results

thanks much

eric
Feb 16 '07 #5
tolkienarda
316 Contributor
ok so i am stupid but here is my question

when i call this new php page do i do it somthing like this

newpage(title);

with newpage being the new php page and title being the variable being sent via GET

eric
Feb 16 '07 #6
Motoma
3,237 Recognized Expert Specialist
ok so i am stupid but here is my question

when i call this new php page do i do it somthing like this

newpage(title);

with newpage being the new php page and title being the variable being sent via GET

eric
No, you will create a page called showImage.php.
When passed an imageid, it will retrieve it from the database and show that picture.
You will then have your other php page output this:
[HTML]
<img src="showImage.php?imageid=5" />
<img src="showImage.php?imageid=76" />
<img src="showImage.php?imageid=549" />
[/HTML]
Feb 17 '07 #7
tolkienarda
316 Contributor
ok thanks sorry for the stupid questions

eric
Feb 18 '07 #8
Motoma
3,237 Recognized Expert Specialist
No worries; everyone was a beginner once.
Feb 18 '07 #9
tolkienarda
316 Contributor
i hopefully wont be a begginer for long i am going to a week training course in php and i hope that after that and some time applying the stuff they teach me i will be at least an ok programer.

eric
Feb 18 '07 #10
tolkienarda
316 Contributor
ok i've tried everthing i can think of and it still won't work. below is the code and a link to the page.
http://www.steppinupwebdesign.com/cms/imgupload.php

the main part of this script is the imgprint() function it is near the bottom
[PHP]
if ($_REQUEST[completed] == 1) {
// Need to add - check for large upload. Otherwise the code
// will just duplicate old file ;-)
// ALSO - note that latest.img must be public write and in a
// live appliaction should be in another (safe!) directory.
move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img");
$image = addslashes(fread(fopen ($_FILES['imagefile']['tmp_name'],'r'),filesize($_FILES['imagefile']['tmp_name'])));
if (strlen($instr) < 149000) {
mysql_query ("insert into pix (title, imgdata, location) values (\"".
$_REQUEST[whatsit].
"\", \"".
$image.
"\")");
} else {
$errmsg = "Too large!";
}
}

imgprint();//calls the image printer after images are uploaded



// If this is the image request, send out the image
/*
if ($_REQUEST[gim] == 1) {
header("Content-type: image/jpeg");
print $bytes;
exit ();
}
*/
?>

<html><head>
<title>Upload image</title>
<body bgcolor=white><h2>latest picture</h2>
<font color=red><?= $errmsg ?></font>
<center><img src=?gim=1 width=144><br>
<table>
<tr>
<td>
<?
function imgprint()
{
$result = mysql_query("SELECT * FROM pix");//this table has an four coloms; title(unique), imgdata, id, location
$rowcount = mysql_num_rows($result);
$i = 1;
while ($i < $rowcount)
{
$row = mysql_fetch_row($result);
$title = $row[title];
echo '<img src="imagedisp.php?title=$title" />';
$i++;
}
}
?>
</table>
<img src="imagedisp.php?title=asdf">
<b><?= $title ?></center>
<form enctype=multipart/form-data method=post>
<input type=hidden name=MAX_FILE_SIZE value=150000>
<input type=hidden name=completed value=1>
browse: <input type=file name=imagefile><br>
comments: <input name=whatsit><br>
then: <input type=submit></form><br>


</body>
</html>
[/PHP]

and here is imgdisp.php

[PHP]

$title = $_GET[title];
$result = "SELECT imgdata, type FROM pix WHERE title='$title'";
$Show = mysql ( $hDB, $hSQL );
$rows = mysql_num_rows($hShow);

if($rows<1){
// no image matches this query
}
else{
// at least one image has this title
$getPhoto = mysql_fetch_object($Show);

// we need to determine the mime type
$Type = $getPhoto->type;

// and send the correct header to the browser
Header("Content-type: $Type");

// now send the image
$Body = $getPhoto->body;
echo $Body;
flush();
}
[/PHP]

thanks eric
Feb 19 '07 #11
Motoma
3,237 Recognized Expert Specialist
ok i've tried everthing i can think of and it still won't work. below is the code and a link to the page.
http://www.steppinupwebdesign.com/cms/imgupload.php
I went to the site, but could not find imagedisp.php which was the src for the img tag.
Feb 20 '07 #12
tolkienarda
316 Contributor
crap i am stupid

the imgdisp.php file is in a subfolder. ahahahahahah i hate being stupid, so frustrating when i do stuff like this it makes me want to kick myself but i am to fat and can't reach my head. oh well i will have to settle for hitting my head against the moniter.

eric
Feb 20 '07 #13
tolkienarda
316 Contributor
hi i am troubleshooting this code one line at a time and i am curious as to what this does

[PHP]
$Show = mysql ( $hDB, $hSQL );
[/PHP]

it is just below my mysql query

eric
Feb 20 '07 #14
Motoma
3,237 Recognized Expert Specialist
hi i am troubleshooting this code one line at a time and i am curious as to what this does

[PHP]
$Show = mysql ( $hDB, $hSQL );
[/PHP]

it is just below my mysql query

eric
This isn't your code?
Spit out $hDB, $hSQL, and $Show. What makes sense?
Check the definition of mysql()
Feb 20 '07 #15
tolkienarda
316 Contributor
i have been stealing bits and pices and i just realized how stupid that is because i end up spending more time troubleshooting the problems than i would if i built it myself and understood what was happening. and i just found a good tutorial that will explain all of the syntax i need to fix this so i will read that before i continue.

thanks for you help i have learned alot i my conversations with you

eric
Feb 20 '07 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
3
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application...
0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
1
by: Bob | last post by:
I have a query whose results contain the full path (i.e. c:\Images\xxx.tiff) to MUTI-PAGE (All two page) TIFF documents. I need to figure out how to BATCH print the tiff's using the path from...
0
by: brettk | last post by:
Thanks to Bob's help, I was able to get .tif printing working. Now i've got a new problem; if the image is more than one page, it only prints the first page. Here's my code: ...
5
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a...
23
by: Kaz Kylheku | last post by:
I've been reading the recent cross-posted flamewar, and read Guido's article where he posits that embedding multi-line lambdas in expressions is an unsolvable puzzle. So for the last 15 minutes...
1
by: Anish G | last post by:
Hi, I am trying to print multiple label images in case of ups multi label implementaion. The response i get in XML schema and from that i parsedout the label images and stored in an array and from...
1
by: Ray Schumacher | last post by:
The class seems to work pretty well - very basic and fast, it just serves images from the specified port and camera device (USB cam). I added an ImageServer class and some code to __main__ class...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.