I used this workaround - if you see something inherently wrong with it, let
me know:

printf("<a href='http://www.mydomain.net/index.asp?type=%s&%s=%s'><b>%s</b>
(%s)</a><br>",$by,$by,$$by,$$by,$total)

So that the output goes like <a
href="http://www.mydomain.net/index.asp?type=type1&type1=value";>type 1
(total#)</a>

And that gets passed to this:
$type = $HTTP_GET_VARS["type"];
$value = $HTTP_GET_VARS[$type];
$result = mysql_query("SELECT * FROM cars WHERE $type ='$value'");

Little more work, but is this safe to use? It's been working great!

-----Original Message-----
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 16, 2002 9:58 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Displaying Results


On Wednesday 17 April 2002 08:21, Jason Soza wrote:
> Sorry, I just noticed that the count() function will do at least the
> first part of my question, i.e. SELECT year, COUNT(*) FROM cars GROUP
> BY year
>
> But the second part still has me a bit stumped. I know that you can
> pass a variable using something like script.php?year=1991, but doesn't
> that assume that in your script you have something like:
> $query = ("SELECT * FROM mytable WHERE year=$year")
>
> So the $year is the only variable that gets replaced by the script.php?
> year=1991 you called it with. How could I make it so that the
> entire 'year=$year' part of the query gets replaced by what comes after
> the ? in script.php?year=1991  ?

You can do something like:

  script.php?qry=year%3D1991

%3D is the url encoding for '='.

Then in your script:

  $query = ("SELECT * FROM mytable WHERE $qry")


--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
The chief danger in life is that you may take too many precautions.
                -- Alfred Adler
*/

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


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

Reply via email to