php变量通过jquery ajax到外部php

i found a php/jquery/ajax script that has a textfield that is sent after the user clicks the input to an external php script to be written into a mysql database. http://gazpo.com/2011/09/contenteditable/

whats missing is the userid passed into the external php file:

$sql = "UPDATE customer SET comment = '$content' WHERE userid = 12345 ";

here is what i do: i am catching the user id in the main file with:

$s = $_GET['contact'];

from the url parameter.

then i put it in to my db select in the main php:

$sql = "select customer from user where userid = $s";  

then there are some div

<div id="content">
    <div id="editable" contentEditable="true">

followed by the ajax script:

$(document).ready(function() {  
    $("#save").click(function (e) {         
        var content = $('#editable').html();
        var content_two = $('#editable_two').html();            
        $.ajax({
            url: 'save2.php',
            type: 'POST',
            data: {
                content: content
            },  

in the save.php there is this:

$content = $_POST['content']; //get posted data     
$sql = "UPDATE customer SET comment = '$content' WHERE userid = "XXXX" ";

So: how do i get the $s variable from my url parameter into the "XXXX"

Add userid to the data you pass from your ajax call back to save.php.

data: {
    content: content,
    userid: <?= $s ?>
}

This is a guess without seeing the rest of your code and how the code actually renders the page.

Thanx alot for the hint.I changed theses lines:

In Ajax/Jquery section of the main php file:

    $("#save").click(function (e) {         
        var content = $('#editable').html()

var nr = <?php echo $s; ?>;

        $.ajax({
            url: 'save.php',
            type: 'POST',
            data: {
            content: content,

nr: nr

            }

And in the external save.php i added this:

$s = $_POST['nr']; 

and also included the variable into $s into my sql update section:

$sql = "UPDATE ADRESSEN SET BEMERKUNG = '$content' WHERE NR = $s ";

This is for a telefonsoftware, when somebody calles me up the software is opening a webpage with the main.php and this variable is using the sql select to show the customer informations, then i write a commend into the editable field and it gets written back into my sql databbase.

So! If somebody is looking for a way to path a url command variable via $_get into a php and then into ajax bach into an external file, i hope he google finds this keywords and is showing this page to help him :)

here its in short:

www.url.com/?contact=12345

php catch url parameter: $s = $_GET['contact'];

sql select: $sql = "select user, userid from customer where userid = $s";

in AJAX/jquery ad:

var nr = <?php echo $s; ?>;

and later on

nr: nr

in external save php:

$content = $_POST['content']; //get posted data

and

$sql = "UPDATE customer SET comment = '$content' WHERE userid = $s ";

As others pointed out in comments that seem to be quitly ignored , you really need to check this out, since the way you build your query is very insecure. Please read about SQL injection.