Autofill without classes

here is my userdata table
123
and below is my gfg.php code, I changed my table name machin1 with userdata (when i was trying diff solution)


// Get the user id
$city = $_REQUEST['city'];

// Database connection
$con = mysqli_connect("localhost", "root", "", "gfg");

if ($city !== "") {
	
	// Get corresponding first name and
	// last name for that user id	
	$query = mysqli_query($con, "SELECT first_name,
	last_name FROM userdata WHERE city='$city'");

	$row = mysqli_fetch_array($query);

	// Get the first name
	$first_name = $row["first_name"];

	// Get the first name
	$last_name = $row["last_name"];
}

// Store it in a array
$result = array("$first_name", "$last_name");

// Send in JSON encoded form
$myJSON = json_encode($result);
echo $myJSON;
?>

So your database has “city” as “Qutera Xeo”, and your code is telling it to look for city “1”.

Do we see why that would not work?

1 Like

so if i change Qutera Xeo with 1 in database, let see it will work or not

oh GOD i am ideot :non-potable_water:

Thanks mate for your help, yes its working now :slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.