Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
trying to insert value from a database into a form
Old 10-01-2010, 04:07 PM trying to insert value from a database into a form
Average Talker

Posts: 17
Name: charlie
Trades: 0
The below code is a form to insert a record into a database (test). I want to be able to key in the apt in the form & insert the name from the database (prerentdb) into the input box. Is this possible ? Sorry, Just learning PHP.
PHP Code:
<?php 
$apt
=$_POST['apt']; 
$name=$_POST['name']; 
$stat mysql_connect(localhost,root,"") or die('Unable to connect to database: ' mysql_error());  
$stat mysql_select_db(prerentdb) or die('Unable to select database: ' mysql_error());  
$query "SELECT apt,name FROM payments WHERE apt='$apt'"
$stat mysql_query($query) or die('Query failed: ' mysql_error());
?>
 
<html> 
<BODY onload="document.form.apt.focus()"> 
<b>Maintenance Log insert form<p> 
<form name=form action="testinsert.php" method="post">
 
<INPUT TYPE="text" size=2 name=apt  
onKeyUp="if(this.value.length==this.size)document.form.name.focus();">Apt#<BR>
 
<INPUT TYPE="text" size=25 name=name>Name<BR>
 
<INPUT TYPE="text" size=10 name=datereceived  
onKeyUp="if(this.value.length==this.size)document.form.time.focus();">Date Received<BR>
 
<INPUT TYPE="text" size=10 name=time>Time Received<BR> 
<INPUT TYPE="text" size=100 name=symptom>Problem<BR> 
<INPUT TYPE="text" size=100 name=action>Action<BR>
 
<INPUT TYPE="text" size=2 name=compmo MAXLENGTH=2  
onKeyUp="if(this.value.length==this.size)document.form.compday.focus();"> 
<INPUT TYPE="text" size=2 name=compday MAXLENGTH=2  
onKeyUp="if(this.value.length==this.size)document.form.compyear.focus();">
 
<INPUT TYPE="text" size=4 name=compyear MAXLENGTH=4  
onKeyUp="if(this.value.length==this.size)document.form.ordno.focus();">Date Completed<br>
 
<INPUT TYPE="text" size=4 name=ordno>Order# -  If Insp<p> 
<p> 
<INPUT type=submit value="submit data"/> 
<BR></form></body></html>
ckdoublenecks is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-01-2010, 04:18 PM Re: trying to insert value from a database into a form
Ultra Talker

Posts: 366
Name: Steve
Location: Miami, FL, Earth
Trades: 0
You'll have to use AJAX to do that. Not a simple thing. Suggest that you learn jQuery + JSON + AJAX and try to implement something then come back here with your solution for more help.
__________________
- Steve

President,
Please login or register to view this content. Registration is FREE
smoseley is offline
Reply With Quote
View Public Profile Visit smoseley's homepage!
 
Reply     « Reply to trying to insert value from a database into a form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33186 seconds with 12 queries