i have a database table called clients CREATE TABLE `CLIENTS` ( `PID` int(11) NO
ID: 3809583 • Letter: I
Question
i have a database table called clients
CREATE TABLE `CLIENTS` (
`PID` int(11) NOT NULL AUTO_INCREMENT,
`CID` char(6) DEFAULT NULL,
`CNAME` varchar(75) DEFAULT NULL,
`CADDRESS` varchar(150) DEFAULT NULL,
`CADDRESS2` varchar(150) DEFAULT NULL,
`CSTATE` char(2) DEFAULT NULL,
`CZIP` char(5) DEFAULT NULL,
`CCOUNTRY` varchar(75) DEFAULT NULL,
`CEMAIL` varchar(75) DEFAULT NULL,
`CPCONTACT` varchar(75) DEFAULT NULL,
`TSTAMP` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`PID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
i want to have an ajax page containing the above information (for example.., i want a add client page where it should ask the values that are there in the table, pid, cid, cname, caddress, caddress2, cstate, czip, cemail, ccountry, ccontact) and then i want to link that page to the database that has the table clients..
Explanation / Answer
The desired page to add clients are given below with ajax:
<html>
<body>
<script language="javascript" type="text/javascript">
<!--
function ajaxClientFunction(){
var ajaxClientRequest;
var pid = document.getElementById('pid').value;
var cid = document.getElementById('cid').value;
var cname = document.getElementById('cname').value;
var cadrr = document.getElementById('cadrr').value;
var cadrr2 = document.getElementById('cadrr2').value;
var cstate = document.getElementById('cstate').value;
var czip = document.getElementById('czip').value;
var ccountry = document.getElementById('ccountry').value;
var cemail = document.getElementById('cemail').value;
var cpcontact = document.getElementById('cpcontact').value;
var queryString = "?pid=" + pid ;
queryString += "&cid=" + cid + "&cname=" + cname + "&cadrr=" + cadrr + "&cadrr2=" + cadrr2 + "&cstate=" + cstate + "&czip=" + czip
+ "&ccountry=" + ccountry + "&cemail=" + cemail + "&cpcontact=" + cpcontact ;
ajaxClientRequest.open("GET", "myClient.php" + queryString, true);
ajaxClientRequest.send(null);
}
//-->
</script>
<form name='myClient'>
PID: <input type='text' id='pid' /> <br />
CID: <input type='text' id='cid' /> <br />
CNAME: <input type='text' id='cname' /> <br />
CADDRESS: <input type='text' id='cadrr' /> <br />
CADDRESS2: <input type='text' id='cadrr2' /> <br />
CSTATE: <input type='text' id='cstate' /> <br />
CZIP: <input type='text' id='czip' /> <br />
CCOUNRTY: <input type='text' id='ccountry' /> <br />
CEMAIL: <input type='text' id='cemail' /> <br />
CPCONTACT: <input type='text' id='cpcontact' /> <br />
<input type='button' value='Add Client'/>
</form>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.