/    Sign up×
Community /Pin to ProfileBookmark

Getting data back from database

Hello,
I am a newbe at php.
I am building a form that needs to go back to the database and get a value when a user fills
in a slef.

Here is what I have so far

[code=php]
<?
$today=date(‘m/d/Y’);
?>
<html>
<head>
<title>Test</title>
<script language=”javascript” src=”pofunctions.js”></script>
<link rel=”stylesheet” type=”text/css” href=”standard.css”>
<script language=’javascript’>
<!–

function lookupStoreAddress(formname)
{
if (str==””)
{
document.getElementById(“test”).innerHTML=””;
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(“test”).innerHTML=xmlhttp.responseText;
}
}

xmlhttp.open(“GET”,”getStoreAddress.php?store=”+str,true);
xmlhttp.send();

}

–>
</script>

</head>
<body

<input class=’inputField’ type=’text’ name=’store’ onblur=”lookupStoreAddress(this)”>
<input class=’inputField’ type=’text’ name=’addressStreet’ readonly=”readonly” size=’40’ >
<input class=’inputField’ type=’text’ name=’city’ readonly=”readonly” size=’40’ >
<input class=’inputField’ type=’text’ name=’state’ readonly=”readonly” size=’40’ >

</body>
</html>
[/code]

I have built a php file, getStoreAddress.php

Based on w3schools
[url]http://www.w3schools.com/php/php_ajax_database.asp[/url]

Which takes in:

[code=php]
<?php
$store=$_GET[“store”];

mysql_close($con);
?>
[/code]

What is the easest/best way to return the values (address, city, state) from getStoreAddress.php
and get them on the main form.

also,
I am not sure what to do with the “test” in lookupStoreAddress

thanks

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @gregd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...