Recuperation d'une variable

Fermé
picasso81 - 27 juin 2011 à 21:28
Bonjour,

j'ai deux pages web une index.htm et l'autre rpc.php

je vous donne le code source et après je vous explique ce que je voulais

index.htm:

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Moteur De Recherche</title>

<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
<script type="text/javascript">
function lookup(inputString) {
if(inputString.length == 0) {
// Hide the suggestion box.
$('#suggestions').hide();
} else {
$.post("rpc.php", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
}
} // lookup

function fill(thisValue) {
$('#inputString').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}

function lookup1(id) {
if(id.length == 0) {
// Hide the suggestion box.
$('#suggestions').hide();
} else {
$.post("rpc.php", {queryString: ""+id+""}, function(data){
if(data.length >0) {
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
}
} // lookup

function fill1(thisValue) {
$('#id').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
</script>

<style type="text/css">
body {
font-family: Helvetica;
font-size: 20px;
color: #000;
}

h3 {
margin: 0px;
padding: 0px;
}

.suggestionsBox {
position: relative;
left: 30px;
margin: 10px 0px 0px 0px;
width: 200px;
background-color: #212427;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border: 2px solid #000;
color: #fff;
}

.suggestionList {
margin: 0px;
padding: 0px;
}

.suggestionList li {

margin: 0px 0px 3px 0px;
padding: 3px;
cursor: pointer;
}

.suggestionList li:hover {
background-color: #659CD8;
}
</style>

</head>

<body>
<center>

<div>
<form form bagcolor='#66CCFF' method='GET' name='formulaire' action='valide.php'>
<div>
Tapez les Trois Premièrs Lettres du Nom:
<br />
<img src="./images/search.png"><br>

<input type="text" size="90" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" /> <br>

</div><p>

<div>
STATUS : <SELECT name="status" size="1">
<OPTION>OK
<OPTION>KO
</select>
</div><p>
Categorie : <SELECT name="cat" size="1">
<OPTION>A
<OPTION>B
<OPTION>C
</select><p>
<?php
echo '<input name="id" value='.$result['id'].' ><br>';
?>

<input type="Submit" value="Valider" onclick="fill();" />


<div class="suggestionsBox" id="suggestions" style="display: none;">
<img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
<div class="suggestionList" id="autoSuggestionsList">
 
</div>
</div>
</form>
</div>
</center>
</body>
</html>



rpc.php

<?php


$db = new mysqli('127.0.0.1', 'root' ,'', 'megabase');

if(!$db) {

echo 'ERROR: Could not connect to the database.';
} else {

if(isset($_POST['queryString'])) {
$queryString = $db->real_escape_string($_POST['queryString']);



if(strlen($queryString) >0) {


$query = $db->query("SELECT value, id, adresse, cp, ville, tel FROM adresses WHERE value LIKE '$queryString%' LIMIT 10");
if($query) {

while ($result = $query ->fetch_object()) {




echo '<li onClick="fill(\' '.$result->id.' '.$result->value.' '.$result->adresse.' '.$result->cp.' '.$result->ville.' '.$result->tel.'\' );"> '.$result->id.' '.$result->value.' '.$result->adresse.' '.$result->cp.' '.$result->ville.' '.$result->tel.'</li>';






}




} else {
echo 'ERROR: There was a problem with the query.';
}
} else {

}
} else {
echo 'There should be no direct access to this script!';
}
}

?>

je cherche à récupéré la variable $result->id pour que je puisse faire un update sur la fiche remontée en se basant sur ID