p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Let's try another tact: passing variable url into a new window.


Message #1 by Jefferis Peterson <jefferis@p...> on Mon, 30 Sep 2002 11:59:57 -0400
Goal: To open a varying image, centered, in a  new window, black background.

I have the data I need. It is being returnd to my page via queries:

MySql $query returns this info: <?php echo $row_viewall['pictures']; ?>

'pictures' is  a field with a url for an image in my website.

If I ad a link to this information:
> <a href='<?php echo $row_viewall['pictures']; ?>'>

It will open a new window with the image.

What I want to do is either
A] paste this link data into an existing php page surrounded by< img src =>

OR, if necessary, 

B] to create a brand new pop up page with the larger image.


So far, I'm not able to pass the information to a new page for A, and for B,
all I get is an uncontrollable image on a large browser page with white
background.  I've been trying in B to use javascript, but it isn't passing
the $query variable, or I'm not getting it right.

Other attempts listed in separate post.

JEff

  ~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year

Message #2 by "Nikolai Devereaux" <yomama@u...> on Mon, 30 Sep 2002 12:33:26 -0700
Hey Jeff,

Been away for a few days, sorry I haven't replied yet.

I don't understand one thing -- how can you expect to have a picture centered
on a page with a black background if the URL you're opening is that picture
directly?  What you need to do is open a link to an HTML page which contains an
IMG tag, and have that HTML page handle centering the img.

> If I ad a link to this information:
> > <a href='<?php echo $row_viewall['pictures']; ?>'>

IN other words, if $row_viewall['pictures'] is '/nik/logo.jpg', then your
hyperlink will open that image directly.

What you need to do to change this is have a single-image page template.  At
it's simplest form, I suggest:

  show_image.php
<HTML>
<HEAD>
  <TITLE>...</TITLE>
</HEAD>
<BODY bgcolor="black">
<DIV align="center">
  <IMG src="<?php $_GET['img']; ?>" />
</DIV>
</BODY>
</HTML>


Now, your href attribute should be set to something like this:

$href = href="show_image.php?img=" . $row_viewall['pictures']";
echo "<a href=\"{$href}\">";


Does this clear things up, or have I missed something in my attempt to catch up
on this thread?

nik

Message #3 by Jefferis Peterson <jefferis@p...> on Mon, 30 Sep 2002 15:53:40 -0400
Nik, this is EXACTLY what I'm looking for. I was trying to use javascript
because I couldn't pass the parameters to a new page and tried to create a
page around the image, but it isn't working.  It is a
hyperlink opening that image directly.

Your code does what I want however, the last line is not working but
producing a parse error.
  $href =   href="show_image.php?img=" . $row_viewall['pictures']";
echo "<a href=\"{$href}\">"; \

Let me show you how I've got it in the file:
>   <a href="javascript:newWindow('<?php echo $row_viewall['pictures'];
> ?>');">LargePictures</a>  <<<<<  PRODUCES A NEW WINDOW WITH PICTURE BUT AS A

 <?php  $href = <a href="show_image.php?img=" .   $row_viewall['pictures']";
> echo "<a href=\"{$href}\">";?>
> 
 I'm not sure how I should place this since the $href variable seems to
stand on its own outside of any link  and by itself no link shows.
Jeff 

On 9/30/02 3:33 PM, "Nikolai Devereaux" <yomama@u...> wrote:

> 
> What you need to do to change this is have a single-image page template.  At
> it's simplest form, I suggest:
> 
> show_image.php
> <HTML>
> <HEAD>
> <TITLE>...</TITLE>
> </HEAD>
> <BODY bgcolor="black">
> <DIV align="center">
> <IMG src="<?php $_GET['img']; ?>" />
> </DIV>
> </BODY>
> </HTML>
> 
> 
> Now, your href attribute should be set to something like this:
> 
> $href = href="show_image.php?img=" . $row_viewall['pictures']";
> echo "<a href=\"{$href}\">";
> 
> 
> Does this clear things up, or have I missed something in my attempt to catch
> up
> on this thread?
> 
> nik
> 

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year

Message #4 by "Gellings, C.O." <gellingsco@p...> on Mon, 30 Sep 2002 22:02:36 +0200
Sorry for intruding but maybe this helps:

$href =   "href=\"show_image.php?img=" . $row_viewall['pictures']."\"";

mth
Carl

-----Original Message-----
From: Jefferis Peterson [mailto:jefferis@p...]
Sent: 30 September 2002 21:54
To: beginning php
Subject: [beginning_php] RE: Let's try another tact: passing variable
url into a new window.


Nik, this is EXACTLY what I'm looking for. I was trying to use javascript
because I couldn't pass the parameters to a new page and tried to create a
page around the image, but it isn't working.  It is a
hyperlink opening that image directly.

Your code does what I want however, the last line is not working but
producing a parse error.
  $href =   href="show_image.php?img=" . $row_viewall['pictures']";
echo "<a href=\"{$href}\">"; \

Let me show you how I've got it in the file:
>   <a href="javascript:newWindow('<?php echo $row_viewall['pictures'];
> ?>');">LargePictures</a>  <<<<<  PRODUCES A NEW WINDOW WITH PICTURE BUT AS
A

 <?php  $href = <a href="show_image.php?img=" .   $row_viewall['pictures']";
> echo "<a href=\"{$href}\">";?>
>
 I'm not sure how I should place this since the $href variable seems to
stand on its own outside of any link  and by itself no link shows.
Jeff

On 9/30/02 3:33 PM, "Nikolai Devereaux" <yomama@u...> wrote:

>
> What you need to do to change this is have a single-image page template.
At
> it's simplest form, I suggest:
>
> show_image.php
> <HTML>
> <HEAD>
> <TITLE>...</TITLE>
> </HEAD>
> <BODY bgcolor="black">
> <DIV align="center">
> <IMG src="<?php $_GET['img']; ?>" />
> </DIV>
> </BODY>
> </HTML>
>
>
> Now, your href attribute should be set to something like this:
>
> $href = href="show_image.php?img=" . $row_viewall['pictures']";
> echo "<a href=\"{$href}\">";
>
>
> Does this clear things up, or have I missed something in my attempt to
catch
> up
> on this thread?
>
> nik
>

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year



Message #5 by "Nikolai Devereaux" <yomama@u...> on Mon, 30 Sep 2002 13:12:48 -0700
Yeah, I screwed up.  too many things open at once, not enough attention to
detail... sigh.

There's a typo -- remove the "href=" after the "$href =".

The working version should be:

$href = "show_image.php?img=" . $row_viewall['pictures']";
echo "<a href=\"{$href}\">";


Carl was closer to the mark because he noticed my typo, but his fix would've
resulted in a bad URL in the href attribute.

I basically split off $href because the entire thing on one line would've
caused an ugly line wrap in most people's email or browser windows, but you
could do it all on one line, if you wanted:


echo "<a href=\"show_image.php?img={$row_viewall['pictures']}\">";


nik

Message #6 by "Gellings, C.O." <gellingsco@p...> on Mon, 30 Sep 2002 22:16:29 +0200
Don't blame yourself Nik, I should have looked at the rest of the code .....
So i f'd up as well

-----Original Message-----
From: Nikolai Devereaux [mailto:yomama@u...]
Sent: 30 September 2002 22:13
To: beginning php
Subject: [beginning_php] RE: Let's try another tact: passing variable
url into a new window.



Yeah, I screwed up.  too many things open at once, not enough attention to
detail... sigh.

There's a typo -- remove the "href=" after the "$href =".

The working version should be:

$href = "show_image.php?img=" . $row_viewall['pictures']";
echo "<a href=\"{$href}\">";


Carl was closer to the mark because he noticed my typo, but his fix would've
resulted in a bad URL in the href attribute.

I basically split off $href because the entire thing on one line would've
caused an ugly line wrap in most people's email or browser windows, but you
could do it all on one line, if you wanted:


echo "<a href=\"show_image.php?img={$row_viewall['pictures']}\">";


nik



Message #7 by "Nikolai Devereaux" <yomama@u...> on Mon, 30 Sep 2002 13:21:06 -0700
> So i f'd up as well

Damn you Carl!!!

:)

Message #8 by Peter Simard <peter@p...> on Mon, 30 Sep 2002 17:02:33 -0400

Play nice...!!!!

;)  ;)


Message #9 by Jefferis Peterson <jefferis@p...> on Mon, 30 Sep 2002 17:29:24 -0400
Okay, this php created link works as so:
http://www.yellow-diamonds.com/a%20href="show_image.php?img=images/B-06A-02.
jpg"

From this code:
<a href='<?php echo "<a
href=\"show_image.php?img={$row_viewall['pictures']}\">";?>'>LargePictures</
a>

So I'm doing something minor wrong I think:
> Not Found
> The requested URL /a href="show_image.php was not found on this server.

Yet the page is on the server.


Jeff 

On 9/30/02 4:12 PM, "Nikolai Devereaux" <yomama@u...> wrote:

> 
> Yeah, I screwed up.  too many things open at once, not enough attention to
> detail... sigh.
> 
> There's a typo -- remove the "href=" after the "$href =".
> 
> The working version should be:
> 
> $href = "show_image.php?img=" . $row_viewall['pictures']";
> echo "<a href=\"{$href}\">";
> 
> 
> Carl was closer to the mark because he noticed my typo, but his fix would've
> resulted in a bad URL in the href attribute.
> 
> I basically split off $href because the entire thing on one line would've
> caused an ugly line wrap in most people's email or browser windows, but you
> could do it all on one line, if you wanted:
> 
> 
> echo "<a href=\"show_image.php?img={$row_viewall['pictures']}\">";
> 
> 
> nik
> 
> 

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year

Message #10 by "Gellings, C.O." <gellingsco@p...> on Mon, 30 Sep 2002 23:29:38 +0200
Pfffffffffffffff, let's be polite ;)

Lucky for me I can't see those icons in my e-mail!!!!!!!!!!!!!!!!!!!

-----Original Message-----
From: Peter Simard [mailto:peter@p...]
Sent: 30 September 2002 23:03
To: beginning php
Subject: [beginning_php] RE: Let's try another tact: passing variable
url into a new window.




Play nice...!!!!

;)  ;)




Message #11 by "Nikolai Devereaux" <yomama@u...> on Mon, 30 Sep 2002 14:45:54 -0700
Jeff,

Take a closer look at what you're outputting!!  Do you see your mistake?


<quote>

From this code:

<a href='<?php echo "<a
href=\"show_image.php?img={$row_viewall['pictures']}\">";?>'>LargePictures</a>

</quote>

You're creating a link to "<a href=...".  If you view the source of your
generated page, you'll see something like this:

<a href='<a href="...">'>

you have two options.

1)  remove the <a href=\" stuff from the PHP code.
2)  remove the <a href=' stuff from the HTML code.


nik


  Return to Index