Page 1 of 1
MySQL SELECT QUESTION & THUMB DISPLAY
Posted: Wed Nov 13, 2002 9:37 am
by cooler75
hello,
I have been working on an upload script, and now it's time to display both orginal and thumbnail on the broswer.
This is my SELECT queries:
Code: Select all
$query = "SELECT * FROM tbl_Files WHERE prop_num = $propnum";
$result = mysql_query ($query) or die(mysql_erro().'<p>'.$query.'</p>');
$query2 = "SELECT * FROM tbl_thumb WHERE prop_num = $propnum";
$result2 = mysql_query ($query2) or die(mysql_error().'<p>'.$query2.'</p>');
$num_images = 0;
while ($image_row =mysql_fetch_array ($result) )
{
<center>
<a href='image.php?Id=$image_rowїid_files]' target="_new">
<img src='$path_to_thumb/$thumb_file_name' height="$displayheight" width="$displaywidth" border="1">
</a>
</center>
}
I have no problem getting the original image displayed on the broswer, however, i am not able to pull the thumbnail image from the directory to show as a link to the original image, it only show a broken link
please advise
and thank you
Posted: Wed Nov 13, 2002 9:46 am
by volka
uh? question is: are in or out a <?php ?> block?
try
Code: Select all
<?php
$query = "SELECT * FROM tbl_Files WHERE prop_num = $propnum";
$result = mysql_query ($query) or die(mysql_erro().'<p>'.$query.'</p>');
$query2 = "SELECT * FROM tbl_thumb WHERE prop_num = $propnum";
$result2 = mysql_query ($query2) or die(mysql_error().'<p>'.$query2.'</p>');
$num_images = 0;
while ($image_row =mysql_fetch_array ($result) )
{ ?>
<center>
<a href="image.php?Id=<?php echo $image_rowїid_files]; ?>" target="_new">
<img src="<?php echo "$path_to_thumb/$thumb_file_name" ?>" height="<?php echo $displayheight; ?>" width="<?php echo $displaywidth; ?>" border="1">
</a>
</center>
<?php
}
?>
Posted: Wed Nov 13, 2002 10:37 am
by cooler75
hi,
that wasnt the problem, i just forgot to put echo in my last message.
I was wondering if there is anything to do with this line here:
Code: Select all
while ($image_row =mysql_fetch_array ($result) )
Can you tell what the problem is? Is there anything else i forgot to do in order to show the thumbnail from the directory?
thanks again
Posted: Wed Nov 13, 2002 10:42 am
by volka
open "view source" in your browser and take a look what really was sent to the client. Does the src-property really contain what you expected?
Posted: Wed Nov 13, 2002 10:59 am
by cooler75
hi,
that's a good way to check
what i see from 'view source' is:
<img src='
http://www.example.com/images/listing_images/' height="108" width="98" border="1">
which is wrong obviously.
what happen to
?
could you please lead me to the right direction?
thank you again
Posted: Wed Nov 13, 2002 1:10 pm
by volka
where does
$thumb_file_name come from? It's in the script only once - when it shall be printed.
Is it a db-field or do you want to create it from a db-field's value (e.g. original image's name is pic1.gif so the thumb must be called pic1_thumb.gif) ?
However there's something missing

Posted: Wed Nov 13, 2002 1:32 pm
by cooler75
hello guru,
definitely something is missing.
$thumb_file_name is a db field with value, your assumption is totally right, pic.jpg is the original image, pic_thumb.jpg is the thumbnail image.
by looking at the database, i see something like that:
Code: Select all
ID owner filename thumb_file_name description prop_num
1 2 bg.jpg thumb_bg.jpg 1
So I know the image was inserted properly, and the thumb has been created successfuly because when i browse my folder, i see the thumbnail there (thumb_bg.jpg).
$thumb_file_name is only appeared once because i have already select it from the database.
my knowledge to this is limited, would probably need some more help.
i will try to think carefully at the same time
thank you
Posted: Wed Nov 13, 2002 1:58 pm
by volka
take a look at the line
Code: Select all
<a href="image.php?Id=<?php echo $image_rowїid_files]; ?>" target="_new">
and how your script access' the field in there. Do the same with the thumbnail field
btw. it should be $image_row['id_files']
