[PHP] Re: javascript & php

2003-07-28 Thread Kristin Schesonka
Hi Roman,

I'm not sure if I understand what you want to do - but if you try to set
your PHP-Variable with JavaScript it couldn't work.
JavaScript is Clientside interpreted and PHP is Serverside interpreted, that
means your PHP-Code is done before the JavaScript-Code.
So the Webserver reads your $color Variable and sees that it is set to
""
This value is obviously not in your database. Then the Webserver sends the
resulting HTML to your browser.

>   $color = "
>";
>
>   $query = mysql_query("select id from color where color = '$color' ");
>   $a = mysql_num_rows($query);

Greetings

Kristin Schesonka



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



[PHP] Re: javascript & php

2003-07-28 Thread Thomas Seifert
On Mon, 28 Jul 2003 12:48:04 +0200 [EMAIL PROTECTED] (Roman Duriancik) wrote:

> I have problem with variables in javascript and php.
> I have code in php and in this code I insert some values from javascript.:
> 
>   $color = "
>";
> 
> 
> when I write command echo $color - result is correct.
> 
> but when i need insert or select some values from database with this 
> value ($color) result is not correct

You are doing it just wrong.
The PHP-code is executed and returns the html-page (with the JS-code if you use the 
print/echo command) to the user 
Afterwards the JavaScript-Code is executed ON THE CLIENT and shows the color in the 
page.
So the color never reaches the php-script.

Get a good book on how JavaScript works at all.


thomas

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



Re: [PHP] Re: Javascript & PHP cookies

2002-06-10 Thread Erik Price


On Sunday, June 9, 2002, at 12:56  AM, John Taylor-Johnston wrote:

> Absolutely. I've done it. Cookies are cookies.
>
> What I don't like is that the cookie is not saved unitl after a submit.
>
> In Javascript, I have JS code that will assign a value and save it to a
> cookie and then recall the cookie value and document.write(myvalue),
> over and
> over if I want, without EVER submitting. It works as the page loads.
>
> Need JS code?

Yes, because it's a client side operation.  Remember, it's the submit 
that is telling the web server to send a cookie.  JavaScript code, being 
client side, can set the cookie without a page submit, just like a 
mathematical calculation can be done without a page submit in JavaScript 
but not with PHP.

To further this clarification, the reason why you can't read the cookie 
that you're setting in the same page is because that cookie was never 
sent to the web server for PHP to recognize.  In other words, you may 
think that because you set a cookie at some point during a given script 
(that is sent to the user agent), that cookie is now available later in 
the same script.  It's not.  The cookie needs to be sent to the web 
server with a page request in order for the web server/PHP to know it's 
there.  This hasn't happened yet.

To beat a dead horse, this is exactly what happens in this order, and 
the steps are separate:

1. User makes a GET/page request of the web server

2. The resource requested on the web server is a PHP script, and one of 
its effects is to say "when this resource is sent to the browser, give 
this cookie along with it"

3. Only AFTER the script executes and is transmitted (thus only AFTER 
the script is actually done doing its work) does the cookie appear on 
the client side.  So the script is unable to "read" the cookie it is 
setting.

4. If the user makes another request to that domain, THEN the cookie is 
available, because the cookie is sent along with that request.

In JavaScript, all of this is done on the client side, so the cookie can 
be read immediately once it is set without the need for requests and 
page submits or what have you.

If you think in terms of HTTP it all makes total sense.



Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




[PHP] Re: Javascript & PHP cookies

2002-06-08 Thread John Taylor-Johnston

Absolutely. I've done it. Cookies are cookies.

What I don't like is that the cookie is not saved unitl after a submit.

In Javascript, I have JS code that will assign a value and save it to a cookie and 
then recall the cookie value and document.write(myvalue), over and
over if I want, without EVER submitting. It works as the page loads.

Need JS code?


> [EMAIL PROTECTED]
> www.tececo.com



[PHP] Re: JavaScript & php question - mainly JS though so slightly OT but hep needed!!! :o)

2001-12-19 Thread Chris Lee

thats exactly how you do it.

foreach( $array as $pos => $val )
echo "
$val 
";

--

  Chris Lee
  [EMAIL PROTECTED]


"Martin Hughes" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> How could I write the function windowPopup(XX) where XX is a variable that
> can change from link to link, for a popup info window to load a php file
> with the variable XX in the url?
>
> So the link would look like:
> Link Text
>
> and I want that link to open the page info.php?patch=XX in a new popup
> window
>
> Do I do it something like this, or is there a faster/better way??
>
> Cheers & Merry X-Mas!
>
> Martin
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]