cuIzgaraKay is a javascript code I want to use it in sql command as cuIzgaraKay.id(it gets the value correctly I checked it). However, I could not it. I googled it but I can’t find what I search . How can i do it ? sorry for asking syntax error but I can’t find it maybe ı have logical error
if(cuIzgaraKay){
<?php
include_once('../phps/kutuphane/inc.php');
$result = mysql_query("select id from bolge_db where parent_id="?>+ cuIzgaraKay.id + <?);
As far as I can tell, you’re trying to execute an SQL query from the PHP page, using data from the Javascript code you’re generating.
The Javascript is only evaluated on the client side of your page. That means that the server-side cannot know anything about the Javascript code.
What you need to do, is to generate the ID, and communicate it to the PHP backend, for example with a HTTP POST/GET request or something.
EDIT:
If you’re new to Javascript, I’d suggest you look into the native JS object XMLHttpRequest. You use it like this:
Or you can use jQuery or a ton of other frameworks to do the same thing.
EDIT:
The method is whatever HTTP request method you want to use. See the wikipedia page for more info: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods
This code will POST to
/page.phpsending a data-string along.If the request returns a successful code, the
ok-callback will be called.On the PHP page, you will need to handle the POST by checking the data and returning an answer if appropriate. Something like this:
If you’ve posted “data1=1234&data2=5678&str=hello%20mum” the $_POST array will look like this: