[thelist] javascript variable in php

Jack Timmons jorachim at gmail.com
Wed May 27 10:35:07 CDT 2009


On Wed, May 27, 2009 at 10:28 AM, Bob Meetin <bobm at dottedi.biz> wrote:
> For the purposes of CSS I can use the IE browser IF statements to manage
> the page.  But say that I have a php script that contains a db query and
> I want to adjust the query according to the browser.
>
> <?php
> $query = "select * from $table";
>
> <!--[if IE6]>
>  <link rel='stylesheet' type='text/css' href='ie6_styles.css' title='stylesheet'> <!-- this is no brainer -->
>  <?php $query = "select * from $table where IE6 = 1;" ?> <!-- passing this along is the part that requires brain cells -->
> <![endif]-->

Well, if you're doing this at page load, you should be able to look at
$_SERVER['HTTP_USER_AGENT'] to identify the browser, if you really
want.

If you're doing it dynamically...I don't see why that wouldn't work
with XMLHttpRequest, but you need to make sure the browser sets the
right user agent when it's doing that. It's not something I've looked
into at all, admittedly.

Am I vaguely shooting in the general vicinity of the right direction?

-- 
-Jack Timmons
http://www.trotlc.com
Twitter: @codeacula



More information about the thelist mailing list