[PHP-DB] find a value in entire table...

2005-04-06 Thread Tristan . Pretty
I need to search an entire table for a value, and then report back what 
field it was found in... how on earth do I do that?
I've a list of departments, as field names.
whenever a user interacts with that Dpet, I wanna add thier id No to the 
appropriate field.
so I'll be left with a table that looks like this:


| Accounts | HR | Support | Marketing |

|  23  | | |  |
| |  17  | |  |
| | |  17  |  |
|  19  | | |  |
| | | | 4  |


So User 17 has dealt with HR and Support, and user 23 has dealt with only 
Accounts.
So I wanna input an user ID no, and then get told what Dpets have been 
accessed...

I need to learn this, as I know it's simple, but I've never had to do it 
before!

Tris

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] One more GD ? -- filename

2005-04-06 Thread Craig Hoffman
Thanks everyone for answering my other post.  However, I'm still having 
trouble passing the image name from the GD script to the image tag.  
I'm including the GD script below. Any help would be great. Thanks - 
Craig

//GD script
?php
	include (db.php);
	$query = SELECT route_photo FROM routes WHERE route_photo IS NOT NULL 
ORDER BY RAND() LIMIT 1;
	$result = mysql_query($query, $db) or die(mysql_error());

while($row = mysql_fetch_array($result)) {
	
	//Photo varibale
		$route_photo = $row[route_photo];
		
	//Start GD
	//New Image resize
		$new_width = 125;
		$new_height = 225;
		
	//Content Type
		header(Content-type: image/jpeg);
		
	//Start new image resize	
		list($width_orig, $height_orig) = 
getImageSize(../images/climbs/$route_photo);
			
		if ($new_width  ($width_orig  $height_orig)) {
$new_width = ($new_height / $height_orig) * $width_orig;
			} else {
$new_height = ($new_width / $width_orig) * $height_orig;
}
	
	//resample the image
		$thumb = ImageCreateTrueColor($new_width, $new_height);
		$tmp_image = ImageCreateFromJPEG(../images/climbs/$route_photo);
		ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width, 
$new_height, $width_orig, $height_orig);
	
		ImageJPEG($thumb, $route_photo, '100');
		ImageDestroy($thumb);
	}
?

//Image Tag:
echo (img src='include/function_gd.php?route_photo=$thumb'  
align='center' id='image');

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] find a value in entire table...

2005-04-06 Thread Martin Norland
[EMAIL PROTECTED] wrote:
I need to search an entire table for a value, and then report back what 
field it was found in... how on earth do I do that?
I've a list of departments, as field names.
whenever a user interacts with that Dpet, I wanna add thier id No to the 
appropriate field.
[snip]
So I wanna input an user ID no, and then get told what Dpets have been 
accessed...

I need to learn this, as I know it's simple, but I've never had to do it 
before!
You'll be better off storing a single row for each user/department 
interaction.  In fact, break them straight out into id's and just have 
it as a linking table

user_department_interactions
|  user_id  |  department_id  |
then have a table for the departments information
departments
|  department_id  |  department_name  |  more fields...  |
a simple join in your query will tell you the department name
select distinct department_name from user_department_interactions where 
user_id=3 AND user_department_interactions.department_id = 
departments.department_id;

the above will return a list of department names that user_id 3 
interacted with.  Whenever they interact with a department you just 
insert a single row into the user_department_interactions table, if you 
only ever want to store whether they interacted at all, you can set 
constraints and catch the error on insert, or search before inserting.

cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] find a value in entire table...

2005-04-06 Thread Tristan . Pretty
that's a fine idea!
I'll hve a play...

Cheers...





Martin Norland [EMAIL PROTECTED] 
06/04/2005 14:51
Please respond to
php-db@lists.php.net


To
php-db@lists.php.net
cc

Subject
Re: [PHP-DB] find a value in entire table...






[EMAIL PROTECTED] wrote:
 I need to search an entire table for a value, and then report back what 
 field it was found in... how on earth do I do that?
 I've a list of departments, as field names.
 whenever a user interacts with that Dpet, I wanna add thier id No to the 

 appropriate field.
[snip]
 So I wanna input an user ID no, and then get told what Dpets have been 
 accessed...
 
 I need to learn this, as I know it's simple, but I've never had to do it 

 before!

You'll be better off storing a single row for each user/department 
interaction.  In fact, break them straight out into id's and just have 
it as a linking table

user_department_interactions
|  user_id  |  department_id  |

then have a table for the departments information

departments
|  department_id  |  department_name  |  more fields...  |

a simple join in your query will tell you the department name

select distinct department_name from user_department_interactions where 
user_id=3 AND user_department_interactions.department_id = 
departments.department_id;

the above will return a list of department names that user_id 3 
interacted with.  Whenever they interact with a department you just 
insert a single row into the user_department_interactions table, if you 
only ever want to store whether they interacted at all, you can set 
constraints and catch the error on insert, or search before inserting.

cheers,
-- 
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] find a value in entire table...

2005-04-06 Thread Juffermans, Jos
Hi,

You could do something like this:


SELECT 'Accounts' as department, Accounts as id FROM mytable WHERE Accounts
IS NOT NULL
UNION ALL   
SELECT 'Human Resources' as department, HR as id FROM mytable WHERE HR IS
NOT NULL
UNION ALL   
SELECT 'Support' as department, Support as id FROM mytable WHERE Support IS
NOT NULL
UNION ALL   
SELECT 'Marketing' as department, Marketing as id FROM mytable WHERE
Marketing IS NOT NULL


Replace mytable with your tablename. 

I know it works on Oracle and I've just tested in on MySql and that works
good too. The query above returned this:

department  | id 
|
Accounts| 23 
Accounts| 19 
Human Resources | 17 
Support | 17 
Marketing   |  4 

Jos


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 14:52
To: php-db@lists.php.net
Subject: [PHP-DB] find a value in entire table...


I need to search an entire table for a value, and then report back what 
field it was found in... how on earth do I do that?
I've a list of departments, as field names.
whenever a user interacts with that Dpet, I wanna add thier id No to the 
appropriate field.
so I'll be left with a table that looks like this:


| Accounts | HR | Support | Marketing |

|  23  | | |  |
| |  17  | |  |
| | |  17  |  |
|  19  | | |  |
| | | | 4  |


So User 17 has dealt with HR and Support, and user 23 has dealt with only 
Accounts.
So I wanna input an user ID no, and then get told what Dpets have been 
accessed...

I need to learn this, as I know it's simple, but I've never had to do it 
before!

Tris

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] One more GD ? -- filename

2005-04-06 Thread Bastien Koert
Have a look here...I have some sample code on calling images from a db. It 
used the two pages like you do here and passes the ID back and forth to the 
image production page...maybe it will help

http://www.weberdev.com/get_example-4062.html
bastien
From: Craig Hoffman [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] One more GD ? -- filename
Date: Wed, 6 Apr 2005 08:23:40 -0500
Thanks everyone for answering my other post.  However, I'm still having 
trouble passing the image name from the GD script to the image tag.  I'm 
including the GD script below. Any help would be great. Thanks - Craig

//GD script
?php
	include (db.php);
	$query = SELECT route_photo FROM routes WHERE route_photo IS NOT NULL 
ORDER BY RAND() LIMIT 1;
	$result = mysql_query($query, $db) or die(mysql_error());

while($row = mysql_fetch_array($result)) {
//Photo varibale
$route_photo = $row[route_photo];
//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;
//Content Type
header(Content-type: image/jpeg);
	//Start new image resize
		list($width_orig, $height_orig) = 
getImageSize(../images/climbs/$route_photo);

if ($new_width  ($width_orig  $height_orig)) {
$new_width = ($new_height / $height_orig) * 
$width_orig;
} else {
$new_height = ($new_width / $width_orig) * 
$height_orig;
}
	//resample the image
		$thumb = ImageCreateTrueColor($new_width, $new_height);
		$tmp_image = ImageCreateFromJPEG(../images/climbs/$route_photo);
		ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width, 
$new_height, $width_orig, $height_orig);

ImageJPEG($thumb, $route_photo, '100');
ImageDestroy($thumb);
}
?
//Image Tag:
echo (img src='include/function_gd.php?route_photo=$thumb'  
align='center' id='image');

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] One more GD ? -- filename

2005-04-06 Thread Craig Hoffman
I believe the problem is somewhere in the GD script.  Because when I 
view the source it shows an empty variable.  I should at least see the 
name of variable in the source.  Any ideas?
img src='include/function_gd.php?route_photo='..'' height='x' 
width='x' align='center' id='image'


On Apr 6, 2005, at 9:46 AM, Bastien Koert wrote:
Have a look here...I have some sample code on calling images from a 
db. It used the two pages like you do here and passes the ID back and 
forth to the image production page...maybe it will help

http://www.weberdev.com/get_example-4062.html
bastien
From: Craig Hoffman [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] One more GD ? -- filename
Date: Wed, 6 Apr 2005 08:23:40 -0500
Thanks everyone for answering my other post.  However, I'm still 
having trouble passing the image name from the GD script to the image 
tag.  I'm including the GD script below. Any help would be great. 
Thanks - Craig

//GD script
?php
	include (db.php);
	$query = SELECT route_photo FROM routes WHERE route_photo IS NOT 
NULL ORDER BY RAND() LIMIT 1;
	$result = mysql_query($query, $db) or die(mysql_error());

while($row = mysql_fetch_array($result)) {
//Photo varibale
$route_photo = $row[route_photo];
//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;
//Content Type
header(Content-type: image/jpeg);
	//Start new image resize
		list($width_orig, $height_orig) = 
getImageSize(../images/climbs/$route_photo);

if ($new_width  ($width_orig  $height_orig)) {
$new_width = ($new_height / $height_orig) * 
$width_orig;
} else {
$new_height = ($new_width / $width_orig) * 
$height_orig;
}
	//resample the image
		$thumb = ImageCreateTrueColor($new_width, $new_height);
		$tmp_image = ImageCreateFromJPEG(../images/climbs/$route_photo);
		ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width, 
$new_height, $width_orig, $height_orig);

ImageJPEG($thumb, $route_photo, '100');
ImageDestroy($thumb);
}
?
//Image Tag:
echo (img src='include/function_gd.php?route_photo=$thumb'  
align='center' id='image');

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] One more GD ? -- filename

2005-04-06 Thread Juffermans, Jos
Hi,

If I understand correctly, you're using
include/function_gd.php?route_photo=$thumb as image source which is the
script you pasted. If you use a script as image source, the script should
output the image data - not just store the image.

I'm not sure what you're trying to do but if you have an image object in php
(eg $thumb), you should output that image:

?php
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image = ImageCreateFromJPEG(../images/climbs/$route_photo);
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width,
$new_height, $width_orig, $height_orig);
header(Content-type: image/jpeg); // tell the browser
to expect a JPG
imagejpeg($thumb, , 100); // send the image to
the browser (filename= = output instead of save)
exit();
?

However, you cannot use that to show multiple images from 1 script.

Jos


-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 15:24
To: php-db@lists.php.net
Subject: [PHP-DB] One more GD ? -- filename


Thanks everyone for answering my other post.  However, I'm still having 
trouble passing the image name from the GD script to the image tag.  
I'm including the GD script below. Any help would be great. Thanks - 
Craig

//GD script
?php
include (db.php);
$query = SELECT route_photo FROM routes WHERE route_photo IS NOT
NULL 
ORDER BY RAND() LIMIT 1;
$result = mysql_query($query, $db) or die(mysql_error());

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

//Photo varibale
$route_photo = $row[route_photo];

//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;

//Content Type
header(Content-type: image/jpeg);

//Start new image resize
list($width_orig, $height_orig) = 
getImageSize(../images/climbs/$route_photo);

if ($new_width  ($width_orig  $height_orig)) {
$new_width = ($new_height / $height_orig) *
$width_orig;
} else {
$new_height = ($new_width / $width_orig) *
$height_orig;
}

//resample the image
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image =
ImageCreateFromJPEG(../images/climbs/$route_photo);
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0,
$new_width, 
$new_height, $width_orig, $height_orig);

ImageJPEG($thumb, $route_photo, '100');
ImageDestroy($thumb);
}
?

//Image Tag:
echo (img src='include/function_gd.php?route_photo=$thumb'  
align='center' id='image');

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] One more GD ? -- filename

2005-04-06 Thread Craig Hoffman
Hi Jos,
I understand what your saying.  The problem is all the image names are 
listed in the DB (image.jpg, image1.jpg and so on)  and all images have 
titles attached.  For example,
Title:  Large Green Sea Turtle
Image: LargeGreenSeaTurtle.jpg

As you can see, the GD script randomly pulls photo names from the DB 
and shows them.  When I output the image with using the image tag I get 
a blank variable.

img src='include/function_gd.php?route_photo='  '' height='x' 
width='x' align='center' id='image'

Since the image name is empty, I can not match/query the title and 
image.  The image output may be showing a  Blue Sea Turtle but the 
title says, Green Sea Turtle. If I could just get the image name, I 
could run a query to match them.  Does this make sense?


On Apr 6, 2005, at 10:36 AM, Juffermans, Jos wrote:
Hi,
If I understand correctly, you're using
include/function_gd.php?route_photo=$thumb as image source which is 
the
script you pasted. If you use a script as image source, the script 
should
output the image data - not just store the image.

I'm not sure what you're trying to do but if you have an image object 
in php
(eg $thumb), you should output that image:

?php
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image = ImageCreateFromJPEG(../images/climbs/$route_photo);
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width,
$new_height, $width_orig, $height_orig);
header(Content-type: image/jpeg);   // tell the browser
to expect a JPG
imagejpeg($thumb, , 100);   // send the image to
the browser (filename= = output instead of save)
exit();
?
However, you cannot use that to show multiple images from 1 script.
Jos
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 15:24
To: php-db@lists.php.net
Subject: [PHP-DB] One more GD ? -- filename
Thanks everyone for answering my other post.  However, I'm still having
trouble passing the image name from the GD script to the image tag.
I'm including the GD script below. Any help would be great. Thanks -
Craig
//GD script
?php
include (db.php);
$query = SELECT route_photo FROM routes WHERE route_photo IS NOT
NULL
ORDER BY RAND() LIMIT 1;
$result = mysql_query($query, $db) or die(mysql_error());
while($row = mysql_fetch_array($result)) {

//Photo varibale
$route_photo = $row[route_photo];

//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;

//Content Type
header(Content-type: image/jpeg);

//Start new image resize
list($width_orig, $height_orig) =
getImageSize(../images/climbs/$route_photo);

if ($new_width  ($width_orig  $height_orig)) {
$new_width = ($new_height / $height_orig) *
$width_orig;
} else {
$new_height = ($new_width / $width_orig) *
$height_orig;
}

//resample the image
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image =
ImageCreateFromJPEG(../images/climbs/$route_photo);
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0,
$new_width,
$new_height, $width_orig, $height_orig);

ImageJPEG($thumb, $route_photo, '100');
ImageDestroy($thumb);
}
?
//Image Tag:
echo (img src='include/function_gd.php?route_photo=$thumb'
align='center' id='image');
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] One more GD ? -- filename

2005-04-06 Thread Juffermans, Jos
Hi,

Are you trying to display more images at once then?

You can store the image like you do now, then have the GD script output the
image tag and use the image you've just stored as a source.

GD script:
...
ImageJPEG($thumb, $route_photo, '100');
echo 'img src=$route_photo width=125 height=225 border=0
title=$route_photo alt=$route_photo /';// add this line
ImageDestroy($thumb);
...


in the other script instead of 
echo (img src='include/function_gd.php?route_photo=$thumb'
align='center' id='image');
do this:
require(include/function_gd.php?route_photo=$thumb);

Jos

-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 18:12
To: php-db@lists.php.net
Cc: Juffermans, Jos
Subject: Re: [PHP-DB] One more GD ? -- filename


Hi Jos,
I understand what your saying.  The problem is all the image names are 
listed in the DB (image.jpg, image1.jpg and so on)  and all images have 
titles attached.  For example,
Title:  Large Green Sea Turtle
Image: LargeGreenSeaTurtle.jpg

As you can see, the GD script randomly pulls photo names from the DB 
and shows them.  When I output the image with using the image tag I get 
a blank variable.

img src='include/function_gd.php?route_photo='  '' height='x' 
width='x' align='center' id='image'

Since the image name is empty, I can not match/query the title and 
image.  The image output may be showing a  Blue Sea Turtle but the 
title says, Green Sea Turtle. If I could just get the image name, I 
could run a query to match them.  Does this make sense?



On Apr 6, 2005, at 10:36 AM, Juffermans, Jos wrote:

 Hi,

 If I understand correctly, you're using
 include/function_gd.php?route_photo=$thumb as image source which is 
 the
 script you pasted. If you use a script as image source, the script 
 should
 output the image data - not just store the image.

 I'm not sure what you're trying to do but if you have an image object 
 in php
 (eg $thumb), you should output that image:

 ?php
   $thumb = ImageCreateTrueColor($new_width, $new_height);
   $tmp_image = ImageCreateFromJPEG(../images/climbs/$route_photo);
   ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width,
 $new_height, $width_orig, $height_orig);
   header(Content-type: image/jpeg); // tell the browser
 to expect a JPG
   imagejpeg($thumb, , 100); // send the image to
 the browser (filename= = output instead of save)
   exit();
 ?

 However, you cannot use that to show multiple images from 1 script.

 Jos


 -Original Message-
 From: Craig Hoffman [mailto:[EMAIL PROTECTED]
 Sent: 06 April 2005 15:24
 To: php-db@lists.php.net
 Subject: [PHP-DB] One more GD ? -- filename


 Thanks everyone for answering my other post.  However, I'm still having
 trouble passing the image name from the GD script to the image tag.
 I'm including the GD script below. Any help would be great. Thanks -
 Craig

 //GD script
 ?php
   include (db.php);
   $query = SELECT route_photo FROM routes WHERE route_photo IS NOT
 NULL
 ORDER BY RAND() LIMIT 1;
   $result = mysql_query($query, $db) or die(mysql_error());

 while($row = mysql_fetch_array($result)) {
   
   //Photo varibale
   $route_photo = $row[route_photo];
   
   //Start GD
   //New Image resize
   $new_width = 125;
   $new_height = 225;
   
   //Content Type
   header(Content-type: image/jpeg);
   
   //Start new image resize
   list($width_orig, $height_orig) =
 getImageSize(../images/climbs/$route_photo);
   
   if ($new_width  ($width_orig  $height_orig)) {
   $new_width = ($new_height / $height_orig) *
 $width_orig;
   } else {
   $new_height = ($new_width / $width_orig) *
 $height_orig;
   }
   
   //resample the image
   $thumb = ImageCreateTrueColor($new_width, $new_height);
   $tmp_image =
 ImageCreateFromJPEG(../images/climbs/$route_photo);
   ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0,
 $new_width,
 $new_height, $width_orig, $height_orig);
   
   ImageJPEG($thumb, $route_photo, '100');
   ImageDestroy($thumb);
   }
 ?

 //Image Tag:
 echo (img src='include/function_gd.php?route_photo=$thumb'
 align='center' id='image');

 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] One more GD ? -- filename

2005-04-06 Thread Craig Hoffman
Hi There (again),
My apologies for being a complete pest with this issue.  I changed a 
few things around and I can now pass the image name thanks to Jos, 
however, I'm getting a permission errors now.

Warning: imagejpeg(): Unable to open 'corneilus.jpg' for writing
I've changed image folder and subfolder permissions to 777 and no luck. 
 Any ideas.
 Again thanks your help. :)

Craig
On Apr 6, 2005, at 11:18 AM, Juffermans, Jos wrote:
Hi,
Are you trying to display more images at once then?
You can store the image like you do now, then have the GD script 
output the
image tag and use the image you've just stored as a source.

GD script:
...
ImageJPEG($thumb, $route_photo, '100');
echo 'img src=$route_photo width=125 height=225 border=0
title=$route_photo alt=$route_photo /'; // add this line
ImageDestroy($thumb);
...
in the other script instead of
echo (img src='include/function_gd.php?route_photo=$thumb'
align='center' id='image');
do this:
require(include/function_gd.php?route_photo=$thumb);
Jos
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 18:12
To: php-db@lists.php.net
Cc: Juffermans, Jos
Subject: Re: [PHP-DB] One more GD ? -- filename
Hi Jos,
I understand what your saying.  The problem is all the image names are
listed in the DB (image.jpg, image1.jpg and so on)  and all images have
titles attached.  For example,
Title:  Large Green Sea Turtle
Image: LargeGreenSeaTurtle.jpg
As you can see, the GD script randomly pulls photo names from the DB
and shows them.  When I output the image with using the image tag I get
a blank variable.
img src='include/function_gd.php?route_photo='  '' height='x'
width='x' align='center' id='image'
Since the image name is empty, I can not match/query the title and
image.  The image output may be showing a  Blue Sea Turtle but the
title says, Green Sea Turtle. If I could just get the image name, I
could run a query to match them.  Does this make sense?

On Apr 6, 2005, at 10:36 AM, Juffermans, Jos wrote:
Hi,
If I understand correctly, you're using
include/function_gd.php?route_photo=$thumb as image source which is
the
script you pasted. If you use a script as image source, the script
should
output the image data - not just store the image.
I'm not sure what you're trying to do but if you have an image object
in php
(eg $thumb), you should output that image:
?php
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image = ImageCreateFromJPEG(../images/climbs/$route_photo);
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width,
$new_height, $width_orig, $height_orig);
header(Content-type: image/jpeg);   // tell the browser
to expect a JPG
imagejpeg($thumb, , 100);   // send the image to
the browser (filename= = output instead of save)
exit();
?
However, you cannot use that to show multiple images from 1 script.
Jos
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 15:24
To: php-db@lists.php.net
Subject: [PHP-DB] One more GD ? -- filename
Thanks everyone for answering my other post.  However, I'm still 
having
trouble passing the image name from the GD script to the image tag.
I'm including the GD script below. Any help would be great. Thanks -
Craig

//GD script
?php
include (db.php);
$query = SELECT route_photo FROM routes WHERE route_photo IS NOT
NULL
ORDER BY RAND() LIMIT 1;
$result = mysql_query($query, $db) or die(mysql_error());
while($row = mysql_fetch_array($result)) {

//Photo varibale
$route_photo = $row[route_photo];

//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;

//Content Type
header(Content-type: image/jpeg);

//Start new image resize
list($width_orig, $height_orig) =
getImageSize(../images/climbs/$route_photo);

if ($new_width  ($width_orig  $height_orig)) {
$new_width = ($new_height / $height_orig) *
$width_orig;
} else {
$new_height = ($new_width / $width_orig) *
$height_orig;
}

//resample the image
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image =
ImageCreateFromJPEG(../images/climbs/$route_photo);
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0,
$new_width,
$new_height, $width_orig, $height_orig);

ImageJPEG($thumb, $route_photo, '100');
ImageDestroy($thumb);
}
?
//Image Tag:
echo (img src='include/function_gd.php?route_photo=$thumb'
align='center' id='image');
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: 

[PHP-DB] Loading images on MYSQL through a PHP web page

2005-04-06 Thread Noel Simela
Hie Guys 

Does anyone know how to load pictures through php to a mysql db...i want
users on my site to be able upload their pictures on the db,whenever i
view their profiles i should be able to see their pics

regards

Noel

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Loading images on MYSQL through a PHP web page

2005-04-06 Thread Bastien Koert
http://www.weberdev.com/get_example-4063.html to load the db
http://www.weberdev.com/get_example-4062.html to get them out
bastien
From: Noel Simela [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Loading images on MYSQL through a PHP web page
Date: Wed, 6 Apr 2005 22:50:48 +0200
Hie Guys
Does anyone know how to load pictures through php to a mysql db...i want
users on my site to be able upload their pictures on the db,whenever i
view their profiles i should be able to see their pics
regards
Noel
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] MySql and PHP question

2005-04-06 Thread ReClMaples
All,

I have a question as how I can return some results that I am looking
for.  Ideally I'd like to run this sql statement but for some reason MySql
won't allow me to run it:


SELECT
  *
FROM
  zip_code
WHERE
  zg_latitude between ((select zg_latitude from zip_code where zg_zipcode =
'78730')- 2) and
  ((select zg_latitude from zip_code where zg_zipcode = '78730') + 2)  and
  zg_longitude between ((select zg_longitude from zip_code where zg_zipcode
= '78730') - 2) and
  ((select zg_longitude from zip_code where zg_zipcode = '78730') + 2)

I get an error to check the mysql manual.  This statement runs in an oracle
environment though.

I guess I am stuck with writing multiple queries and them tying them
together.  In PHP how can I put a variable into the sql statement (if that's
possible).  Let's say I have these queries:
select zg_longitude from zip_code where zg_zipcode = '78730'

This one pulls the zg_longitude from the zip_code table where the zip_code
is 78730 for instance.  I want to take the result (one record) and put it in
this sql statment replacing 'result here':

select * from zip_code
where zg_longitude = ('result here'-2)
and zg_longitude = ('result here'+2)
order by zg_city asc

Can anyone help me with this or point me in a better direction?

Thanks

-Rich