Re: javascript in PHP statement
| From: | Michael Hall | Date: | Thu, 15 Feb 2001 20:05:38 +0000 |
| Subject: | Re: javascript in PHP statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39983@lists.php.net to get a copy of this message | ||
> I am new to php and I am wondering if it is possible to use a javascript
> variable in a php statement for example:
>
> // create sql statement
>
> $sql = "select * from main where businesstype = "consultancy" and
> top.upper.villagename = != "0";";
As far as I know, no. Unless "top.upper.villagename" is a field in your
database and the rest is that field's contents (couldn't be ... too many
unescaped double quotes and semicolons). Nope, SQL statements don't work
like that and can only refer directly to data in a database, not php or
any other variables.
You might consider using if statements something like this:
if ($top.upper.villagename != '0') {
$sql = "SELECT * FROM main WHERE business = 'consultancy'";
}
Hope this helps
Mick