View Single Post
Old 02-10-2013, 02:46 PM   PM User | #1
GuardPH
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
GuardPH is an unknown quantity at this point
How to Get the ID variable of input type txt

Hi... I need to get the ID variable of DropDown form then pass it to result.php - But I can't get to make it work... Help!

main.php
Code:
<script>
<?php
$user = $_GET["user"];
?>
 $(document).ready(function(){
	var user = '<?php echo $user ;?>';
  $("#tag").autocomplete('/find/autocomplete.php?user='+user, 
  {
        selectFirst: true
  });
 });
</script>

<form method="post" action="result.php">
<input style="padding:2px 5px 2px 5px;font-family:verdana;font-size:11px;color:#444444" name="tag" type="text" id="tag" size="50"/>
<INPUT type="submit" value="Submit" style="background-color:grey; font-family: verdana; font-size: 10px; color:#fff;">
</form>
autocomplete.php --- This will Populate the dropdown [id] [company]
Code:
<?php
	
	$q=$_GET['q'];
	$user = $_GET['user']; 
	$my_data=mysql_real_escape_string($q);
	$mysqli=mysqli_connect('localhost','root','root101','uaeexchange') or die("Database Error");
	$sql="SELECT comp_name,id FROM viewreport2 WHERE user='$user' AND comp_name LIKE '%$my_data%' ORDER BY comp_name";
	$result = mysqli_query($mysqli,$sql) or die(mysqli_error());
	
	if($result)
	{
		while($row=mysqli_fetch_array($result))
		{
			echo "[".$row['id']."]  ".$row['comp_name']."\n";
		}
		
		
	}
	
?>
result.php - this will redirect back to main page.
Code:
<?php

if(isset($_POST['Submit']))
	{ 	
    $id = $_GET['tag'];
    $user = $_GET['user'];
	}
//	header("Location: http://localhost/crmview.php?id=".$id."?T1=".$text);
header('Location: main.php?id='.$_POST['id'].'&user='.$_POST['user'].'');
?>
GuardPH is offline   Reply With Quote