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
need help autoinserting values
Old 12-08-2010, 10:25 PM need help autoinserting values
Average Talker

Posts: 17
Name: charlie
Trades: 0
I've created a bear here with this little program. I need to include the below code in the existing working program. Can someone help?
[ICODE]// ************************************************** **
var balance;
var stillowed;
balance = rentdue + prevbal + misc - hudpay;
stillowed = balance - amtpaid;
function isitlate(dayNow)
{
if(dayNow > 5){late = "L";
prevbal = stillowed + 10;
}
}
// ************************************************** [/ICODE]
[CODE]<html><head>
<script>
function calculate_paid(v)
{
var amtpaid = document.getElementById("amtpaid");
var tentpay = document.getElementById("tentpay");
var hudpay = document.getElementById("hudpay");
var datepaid = document.getElementById("datepaid");
var late = document.getElementById("late");
var dateNow = new Date();
var dayNow = dateNow.getDate();
var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
switch(v)
{
case amtpaid:
var tpay = amtpaid.value - hudpay.value;
if(tpay >= 0){tentpay.value = tpay;}
if(amtpaid.value > 0){datepaid.value = datePaid;}
break;
case tentpay:
if(!hudpay.value || hudpay.value == " "){hudpay.value = 0;}
if(!tentpay.value || tentpay.value == " "){tentpay.value = 0;tentpay.select();}
amtpaid.value = parseInt(tentpay.value) + parseInt(hudpay.value);
if(tentpay.value > 0){datepaid.value = datePaid;}
break;
case hudpay:
if(!tentpay.value || tentpay.value == " "){tentpay.value = 0;}
if(!hudpay.value || hudpay.value == " "){hudpay.value = 0;hudpay.select();}
amtpaid.value = parseInt(tentpay.value) + parseInt(hudpay.value);
if(hudpay.value > 0){datepaid.value = datePaid;}
break;
}
}
</script>
<script type="text/javascript">
window.google_analytics_uacct = "UA-256751-2";
</script>
<script type="text/javascript">
window.google_analytics_uacct = "UA-256751-2";
</script>
</head><body>[/CODE
PHP Code:
]<?php
mysql_connect
(localhost,root,"");
mysql_select_db(prerentdb) or die( "Unable to select database");
if(!empty(
$_POST["submit"]))
{
$apt $_POST['apt'];
$query="SELECT * FROM payments Where apt='$apt'";
$result=mysql_query($query);
if(
mysql_num_rows($result))
{
echo 
"<form action='#' method='post'><b>Rent Payment :<br /><br />
<table cellspacing=0 cellpadding=0 border=1>
<tr>
<th>dep</th>
<th>tenant</th>
<th>apt</th>
<th>paid</th>
<th>due</th>
<th>prev</th>
<th>misc</th>
<th>tent</th>
<th>hud</th>
<th>date</th>
<th>late</th>
<th>comments</th>
</tr>"
;
while(
$row mysql_fetch_assoc($result))
{
echo 
"<tr>
<td><input type='text' size=5 name='dep' value='" 
$row['dep'] . "'></td>
<td><input type='text' size=25 name='name' value='" 
$row['name'] . "'></td>
<td><input type='text' size=2 name='apt' value='" 
$row['apt'] . "' ></td>
<td><input type='text' size=4 id='amtpaid' name='amtpaid' value='" 
$row['amtpaid'] . "'></td>
<td><input type='text' size=4 name='rentdue' value='" 
$row['rentdue'] . "'></td>
<td><input type='text' size=4 name='prevbal' value='" 
$row['prevbal'] ."'
onkeyup='calculate_paid(this)></td>
<td><input type='text' size=4 name='misc' value='" 
$row['misc'] . "'></td>
<td><input type='text' size=4 id='tentpay' name='tentpay' value='" 
$row['tentpay'] . "' 
onkeyup='calculate_paid(this)'></td>
<td><input type='text' size=4 id='hudpay' name='hudpay' value='" 
$row['hudpay'] . "'></td>
<td><input type='text' size=10 id='datepaid' name='datepaid' value='" 
$row['datepaid'] . "'></td>
<td><input type='text' size=1 name='late' value='" 
$row['late'] . "'
onkeyup='calculate_paid(this)'></td>
<td><input type='text' size=25 name='comments' value='" 
$row['comments'] . "'></td>
</tr>"
;
}
echo 
"</table>
<input type='submit' name='update' value='Make Payment' />
</form>"
;
}
else{echo 
"No listing for apartment $apt.<br />Please select another.<br />";}
}
if(!empty(
$_POST["update"]))
{
$sql "UPDATE payments SET
dep = '" 
mysql_real_escape_string($_POST['dep']) . "',
name = '" 
mysql_real_escape_string($_POST['name']) . "',
amtpaid = '" 
mysql_real_escape_string($_POST['amtpaid']) . "',
rentdue = '" 
mysql_real_escape_string($_POST['rentdue']) . "',
prevbal = '" 
mysql_real_escape_string($_POST['prevbal']) . "',
misc = '" 
mysql_real_escape_string($_POST['misc']) . "',
tentpay = '" 
mysql_real_escape_string($_POST['tentpay']) . "',
hudpay = '" 
mysql_real_escape_string($_POST['hudpay']) . "',
datepaid = '" 
mysql_real_escape_string($_POST['datepaid']) . "',
late = '" 
mysql_real_escape_string($_POST['late']) . "',
comments = '" 
mysql_real_escape_string($_POST['comments']) . "'
WHERE apt='"
.$_POST["apt"]."'";
mysql_query($sql) or die("Update query failed.");
echo 
"Record for apartment ".$_POST["apt"]." has been updated";
}
?>
Code:
<form method="post" action="#">
<br />
<input type="text" name="apt"/> <p>
<input type="submit" name="submit" value="select apartment"/>
</form>
<script type="text/javascript"><!--
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' 
type='text/javascript'%3E%3C/script%3E"));
//-->
</script>
<script type="text/javascript"><!--
try {
var pageTracker = _gat._getTracker("UA-256751-2");
pageTracker._trackPageview();
} catch(err) {}
//-->
</script>
<script type="text/javascript"><!--
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' 
type='text/javascript'%3E%3C/script%3E"));
//-->
</script>
<script type="text/javascript"><!--
try {
var pageTracker = _gat._getTracker("UA-256751-2");
pageTracker._trackPageview();
} catch(err) {}
//-->
</script>
</body></html>
ckdoublenecks is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to need help autoinserting values
 

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.15871 seconds with 12 queries