Jump to content

passing multiple variable


phpfreaksFTW

Recommended Posts

any ideas how this can be done? right now i search, in the drop down box show the s_last and s_first when i click on the one i want the s_last gets filled in the box. i would like to do a search on the id of that name. right now i have this

 

this is my rpc.php

<?php
$db = new mysqli(");

if(!$db) {
    // Show error if we cannot connect.
    echo "ERROR: Could not connect to the database.";
} else {
	if(isset($_POST['queryString'])) {
		$queryString = $db->real_escape_string($_POST['queryString']);
		$one = $_POST['one'];
		if(strlen($queryString) >0) {


 $query = $db->query("SELECT $one, s_last, s_first, id FROM table_student WHERE $one LIKE '$queryString%' LIMIT 10");

		   
		if($query) {

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


			//	echo '<li onClick="fill(\''.$result->s_last.'\');">'.$result->s_last.'</li>';
			echo '<li onClick="fill(\''.$result->s_last.'\',\''.$result->s_first.'\');">'.$result->s_last.', ' .$result->s_first.'</li>';

				//echo '<li onClick="fill(\''.$result->s_last.$result->s_first.'\');">' .$result->id.'</li>';
			//echo '<li onClick="fill(\''.$result->s_last.'\',\''.$result->s_first.'\');">' .$result->s_first.'</li>';
         
         		}

			} else {
				echo 'ERROR: There was a problem with the query.';
			}
		} else {
			// Dont do anything.
		} // There is a queryString.
	} else {
	//	echo 'There should be no direct access to this script!';

	}}

?>

 

i would like to when i click on the name for it to show first last name however when i press search for it to send to another php page the id of the first and last name?

 

this is my javascript now

script type="text/javascript">
function lookup(inputString) {
	if(inputString.length == 0) {
// Hide the suggestion box.
$('#suggestions').hide();

} else {
$.post("rpc.php",{queryString:""+inputString+"",one:""+$("#oneone").val()+""},function(data){

if(data.length >0) {
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
	}
} // lookup


/////////////////////
/////////////////////

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


///////////////////////////////////////////////
//////////////////////////////////////////////






 function inputter(element)
            {
            parent.location='1.php?option=s_ladst&id=' + escape(element);
        
        }

        $(document).ready(function() {
            
         $('#inputString').keyup(function(e) {
       
        if(!e) e = window.event;

        if(e.keyCode == 13) {
            inputter(document.getElementById('inputString').value);
        }
         }
         
            )
        } )

		////////////////
		////////////////
		///////////////
</script>

 

 

this is my html page now

body>


<div>
<form method="get">
<div>
Type your county:
<br />
           
     <select id="oneone" value=""> 
     <option value="s_city">city</option>
  	<option value="s_last">Last</option>
  	<option value="s_first">First</option>
</select>

<input type="text" size="30" value="" autocomplete="off" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" />
    <input type="text" size="30" value="" autocomplete="off" id="inputString"  onblur="fill();" />
    <input type="button" value="Search!" onClick="inputter(document.getElementById('inputString').value)"> 
</div>

<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>

</body>
</html>


 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.