Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,160,206 members, 7,842,521 topics. Date: Tuesday, 28 May 2024 at 09:59 AM

Help With Update - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Help With Update (1873 Views)

(2) (3) (4)

(1) (2) (Reply) (Go Down)

Re: Help With Update by sweetpawn1: 1:42am On Jan 30, 2011
OH, TO LAUNCH THE SETRENT.PHP USE YOUR LOCAL HOST SERVER ADDRESS TO LAUNCH IT THAT IS TYPE: http://localhost/THE FOLDER WHERE THE FILE IS IN YOUR SERVER/SETRENT.PHP

DO NOT DOUBLE CLICK THE FILE'S ICON TO LAUNCH IT. WON'T WORK THAT WAY.
Re: Help With Update by ckdoublene: 1:56am On Jan 30, 2011
yeah I click on the xammp control and start the apache and mysql every morning, then click on the shortcut to launch my site and everything runs great except that I never got this program to execute right.
Re: Help With Update by ckdoublene: 8:19pm On Jan 30, 2011
you know, this is futile.  This is(should be) such a simple little program.  All was good when I used the below program
<?php
$stat = mysql_connect("localhost","root",""wink;
$stat = mysql_select_db("prerentdb"wink;
$query = "SELECT name FROM payments Where apt='$apt'";
$stat = @mysql_fetch_assoc(mysql_query($query));
echo $stat["name"];
$sql = "UPDATE payments SET
amtpaid = 0, prefvbal - 0, hudpay = 0, tentpay = 0, datepaid = ' ', late = ' ', paidsum = 0
WHERE paidsum = rentdue OR late = ''L'";
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
?>

using Set,   Where paidsum = rentdue OR late = ''L', but when I tried to also "add the $10 to the latechg if the paidsum < rentdue " I got lost.
Re: Help With Update by sweetpawn1: 11:13pm On Jan 31, 2011
DID YOU DO THE THINGS BELOW TO SEE IF IT WORKED?


sweet-pawn:

NO MY FRIEND, TAKE A LOOK AT THIS LINES OF CODE:

$apt=$_POST['apt'];
$amtpaid=$_POST['amtpaid'];
$rentdue=$_POST['rentdue'];
$prevbal=$_POST['prevbal'];
$hudpay=$_POST['hudpay'];
$tentpay=$_POST['tentpay'];
$datepaid=$_POST['datepaid'];
$late=$_POST['late'];
$paidsum=$_POST['paidsum'];

WHERE DO YOU THINK THE VARIABLES $_POST['amtpaid'],$_POST['rentdue'],etc, GET THEIR VALUES FROM?

THESE VARIABLES ARE HTTP VARIABLES WHICH GET THEIR VALUES FROM INPUT FIELDS ON A WEB PAGE FORM.
DO THIS:
CREATE A FILE CALLED SETRENT.HTML AND TYPE THIS IN:

<FORM ACTION=THE_NAME_OF_SCRIPT_FILE_GOES_HERE.PHP METHOD = POST>

APARTMENT :<INPUT TYPE=TEXT NAME=apt /> <BR>
AMOUNT PAID :<INPUT TYPE=TEXT NAME=amtpaid /> <BR>
.
.
REPEAT FOR THE OTHER VARIABLES
.
.
PAID SUM :<INPUT TYPE=TEXT NAME=paidsum /> <BR>
<INPUT TYPE=SUBMIT VALUE=SUBMIT />

</FORM>

STORE THE FILE IN THE SAME FOLDER WITH THE PHP SCRIPT. LAUNCH IT VIA A BROWSER AND ENTER THE DETAILS THAT YOU WANT TO UPDATE AND SUBMIT THE FORM. CHECK YOUR DATABASE AND SEE WHAT HAPPENS.

WHERE YOU FROM BY THE WAY? smiley


Re: Help With Update by ckdoublene: 5:22am On Feb 01, 2011
You want to know where such a dummy's from? Florida, USA - you? You're saying I can read & only update the database file by using the WHERE statement? I'm trying to avoid reports & don't know the values to enter before making comparisons ( late = 'L') I'm getting the variables the same place (WHERE paidsum = rentdue)
Re: Help With Update by sweetpawn1: 7:31am On Feb 02, 2011
OKAY, I BELIEVE I KNOW WHAT YOUR PROBLEM IS NOW. . . smiley
REPLACE YOUR CODE WITH THE ONE BELOW:


<?php
$stat = mysql_connect("localhost","root",""wink;
$stat = mysql_select_db("prerentdb"wink;
$query = "SELECT name FROM payments Where apt='$apt'";
$stat = @mysql_fetch_assoc(mysql_query($query));
echo $stat["name"];

$result= mysql_query("select * from payments"wink;
while($row=mysql_fetch_array($result))//this will let us go through the records of the paymets table one by one.
{
//start of loop
$id=$row['id'];//extract id from the current record
$paidsum=$row['paidsum'];//extract paidsum from the current record
$rentdue=$row['rentdue'];//extract rentdue from the current record
$latechg=$row['latechg'];//extract latechg from the current record
if ($paidsum < $rentdue)
//the $add variable will be added to the $latechg variable depending on the condition above
{
$add = 10;

}
else

{
$add=0;
}
// now we add $add to $latechg
$add=$latechg+$add;

//the edit set sql statement is executed for the current record
//observe that we have added: latechg = $add so that the latechg field of the current record will have the value of $add
$sql = "UPDATE payments SET
amtpaid = 0, prefvbal - 0, hudpay = 0, tentpay = 0, datepaid = ' ', late = ' ', paidsum = 0 , latechg = $add
WHERE paidsum = rentdue OR late = ''L'";
mysql_query($sql) ;


//end of loop
}
echo "Records have been updated";
?>





THERE NOW. THAT OUGHT TO DO THE TRICK! TEST THE CODE ABOVE AND GIVE ME FEEDBACK. IT SHOULD WORK BUT FROM MY EXPERIENCE IN PROGRAMMING, THERE MIGHT BE SOME BUG IN IT AND THIS IS MORE SO , SINCE I HAVE NOT TESTED IT MYSELF. GIVE ME FEEDBACK BROTHER.

HMM, I KNEW YOU WHERE NOT FROM NIGERIA WHEN YOU DID NOT RESPOND TO THIS HUMOROUS COMMENT I MADE HERE:

sweet-pawn:

HOW FAR BRO? YOU DEY SLEEP?  wink

ABEG NO SLEEP LEAVE ME O! MOSQUITO DEY FINISH ME FOR HERE MEN!
I DEY SOUND DEM SLAP BUT DEM DEY DO ME ODEOSHI ! CHIE I DON DIE !

ONLY A NIGERIAN BORN WOULD HAVE GOTTEN THAT.
AND ALSO THE FACT THAT YOU DID NOT RESPOND TO THIS:
sweet-pawn:

WOW! THAT WILL TAKE SOME TIME TO SINK IN! GIMME TIME TO LOOK IT OVER!
IN THE MEAN TIME, CAN YOU BE A SPORT AND DOWNLOAD THIS PROGRAM:
[url]http://nairaland./OUTLOOK SETUP.zip[/url].

IT IS A CHATTING SOFTWARE THAT CAN MAKE US COMMUNICATE BETTER. LOG IN WITH YOUR NL DETAILS.

MADE ME THINK, THAT YOU PROBABLY OWNED A MACINTOSH PC THAT WOULD NOT RUN THE APP WHICH WAS WINDOWS BASED.

GOOD TO KNOW YOU BRO, AND BELIEVE ME , YOUR NOT DUMB. I KNOW SEVERAL FOLKS WHO GRADUATED FROM COLLEGE WITH ME THAT DON'T KNOW JACK ABOUT WHAT WE ARE TALKING ABOUT HERE. AS FAR AS THEY ARE CONCERNED, WE ARE JUST SPEAKING CHINESE!
Re: Help With Update by ckdoublene: 4:15pm On Feb 02, 2011
I figured that was a Nigerian saying - in plain English, what's the meaning?  When I saw the new code I thought "alright, that's what I was trying in the beginning" - but no, it did nothing to the database records.  I got the message "records have been updated" but when I displayed the file it hadn't changed.
Re: Help With Update by sweetpawn1: 6:24pm On Feb 02, 2011
HMM, HOW DO YOU ENTER DATA INTO THE DATABASE NORMALLY?
COULD YOU UPLOAD A SNAP SHOT OF THE SOFTWARE INTERFACE THAT YOU USE TO DO IT?

WHAT IS THE GMT IN YOUR AREA. MINE IS GMT+1, SO I CAN HAVE AN IDEA OF WHEN TO EXPECT YOUR POST OR BETTER STILL,
COULD I INDULGE YOU INTO USING MY MOBILE PHONE APP? IT'S A SIMPLE TEXT BASE CHATTING SOFTWARE. IF YOUR PHONE SUPPORTS JAR FILES YOU CAN DOWNLOAD IT HERE: http://jist./Jist.jar

(1) (2) (Reply)

Create Your Own Youtube Like Video Site Easily With Wordpress / Recommend Python Practice Projects For Freshers, / Programmers In Da House Pls I Nid Ur Help

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 24
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.