Connecting Tech Pros Worldwide Help | Site Map

Printing image.

Newbie
 
Join Date: Oct 2006
Posts: 23
#1: Oct 17 '06
PHP Version:4.3.9 win32

Problem: I try to print the image from table dollsimage , gameandtoyname and the pricetype from dolls. (i have 7 images and 7 gameandtoyname), but This code prints only 3 borders.
What i am doing wrong? i think the problem is with the $str.
Pleas help!

[PHP]
<?php


$sql = ("SELECT gameandtoyname, pricetype, dollsimage.image_id, dollsimage.image_date
FROM dollsimage, dolls
WHERE dollsimage.image_id = dolls.image_id
ORDER BY image_date DESC");

$result = mysql_query ($sql, $conn);

if (!$result) {
die('Invalid query: ' . mysql_error());
}

$str = "";
if (mysql_num_rows($result) > 0)


{
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

$i++;
$image_id = $row["image_id"];
$gameandtoyname = $row["gameandtoyname"];
$pricetype = $row["pricetype"];
$str .="$i. <img border='1' height='90' width='100' src='imagedolls.php?act=view&iid=$image_id$gameand toyname$pricetype'></a> ";

}
print $str;
}



?>

[/PHP]
Newbie
 
Join Date: Oct 2006
Location: Beside my computer :)
Posts: 13
#2: Oct 18 '06

re: Printing image.


Need a code from script: imagedolls.php.
Problems in it or wrong parameters for it.
Newbie
 
Join Date: Oct 2006
Posts: 23
#3: Oct 18 '06

re: Printing image.


Sir here is the imagedolls.php:

Thanks

[PHP]
<?php


// database connection
$conn = mysql_connect("localhost", "root") OR DIE (mysql_error());
@mysql_select_db ("products", $conn) OR DIE (mysql_error());
$sql = "SELECT * FROM dollsimage WHERE image_id=".$_GET["iid"];
$result = mysql_query ($sql, $conn);
if (mysql_num_rows ($result)>0) {
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
$image = $row["image"];
Header ("Content-type: $image_type");
print $image;
}
?>

[/PHP]
Newbie
 
Join Date: Oct 2006
Location: Beside my computer :)
Posts: 13
#4: Oct 19 '06

re: Printing image.


Hm-m, script is clear.
In your database must be record where field
image_id=$image_id$gameandtoyname$pricetype
or
you have mistake in here:
src='imagedolls.php?act=view&iid=$image_id$gameand toyname$pricetype'
try correct to:
src='imagedolls.php?act=view&iid=$image_id'
Newbie
 
Join Date: Oct 2006
Posts: 23
#5: Oct 20 '06

re: Printing image.


Quote:

Originally Posted by brid

Hm-m, script is clear.
In your database must be record where field
image_id=$image_id$gameandtoyname$pricetype
or
you have mistake in here:
src='imagedolls.php?act=view&iid=$image_id$gameand toyname$pricetype'
try correct to:
src='imagedolls.php?act=view&iid=$image_id'

Thanks alot. You did help me.
Reply