radar
Members-
Posts
645 -
Joined
-
Last visited
About radar
- Birthday 01/08/1982
Contact Methods
-
Website URL
http://www.amplifiedwebservices.com
Profile Information
-
Gender
Male
-
Location
SLC
radar's Achievements
Regular Member (3/5)
0
Reputation
-
what that formula does, is take the numbers... for P i M and q, and calculate how long it would take to pay off a debt in years.. then to get the months, times it by 12..
-
decimal screws it up though.. i have no way of knowing how long the strings should or will be... and all the extra 0's seem to screw something up in the math i think... i put type double in, which seems to allow my decimals.. and with nothing added in (65,30) it seems to work with me manually entering them in which means it should work when they are generated? note: its generated from $n = -log(1-($P * $i / ($M * $q))) / ($q * log(1+($i/$q))); where $P is principal debt, $i is interest, $M is monthly payment and $q is 12 (12 months in a year).. then that number is multiplied by 12 to get the total number of months. so it'll always be a decimal, i just have no way of knowing how long it'll be.
-
is it varchar, but which numerical datatype to use? decimal and int both seem to remove the decimal points.
-
I have a query that is effectively: SELECT * FROM tables WHERE p_id = $p_id ORDER BY months_remain ASC The query gets run correctly, but the results aren't correct at all.. It happens in my code, as well as in phpmyadmin and I can't figure out why.. I'm using php 5 and mysql 5.0.91 the output of the query looks like: Array ( [0] => Array ( [id] => 10 [u_id] => 2 [p_id] => 1 [descrip] => Car 2 [reason] => [interest] => 0.06 [months_remain] => 196.655857568 [month_payment] => 520 [principal_debt] => 65000 [real_debt] => 102261.045936 ) [1] => Array ( [id] => 6 [u_id] => 2 [p_id] => 1 [descrip] => car [reason] => [interest] => 0.052 [months_remain] => 25.3967600188 [month_payment] => 100 [principal_debt] => 2400 [real_debt] => 2539.67600188 ) [2] => Array ( [id] => 7 [u_id] => 2 [p_id] => 1 [descrip] => house [reason] => house [interest] => 0.052 [months_remain] => 254.07482305 [month_payment] => 1300 [principal_debt] => 200000 [real_debt] => 330291.00 ) ) note that in this list that it is not sorted by months_remain as it's showing that 196.65.... is less than 25.3967.... any ideas why this might be happening?
-
Alright, I'm building a registration form but I want everything to be on the right side of the containing div that it's in... <div id="container"> <div id="register"> <h1>Register</h1> <form class="right" action = ""> <ul> <li><label for="name" class="desc">Name: </label><input name="name" type="text" size="30%"></li> <li><label for="email" class="desc">Email: </label><input name="email" type="text" size="30%"></li> <li><label for="password" class="desc">Password: </label><input name="password" type="password" size="30%"></li> <li><label for="password2" class="desc">Confirm Password: </label><input name="password2" type="password" size="30%"></li> </ul> </form> </div> <div id="login"> <h1>Login</h1> </div> </div> I can get both the label and the input to float to the right, but the problem is that when i do it the label is on the right side of the form input unless i put the form input before the label. anyone have any ideas?
-
beautiful. thanks xyph... saves me a ton of hassle within the next day or two... I really appreciate it.
-
Ahh just thought of something else, because the end-user will be able to input their interest rate at 10, 29.5 or any number inbetween 0 and 100%.. how would i use php to modify that into a decimal for use with this equation
-
man you guys are awesome.... In my years of programming php I've never had to do this type of math before so figuring out how to write it (being that i suck at math - almost 30 and can barely add and subtract really) was going to be a pain in the butt..... thank you guys very much for helping me out I really appreciate it!
-
This is about the worst math i've ever seen... i HATE math.... any help is appreciated... The mathematical equation as based on actual math is: n = -log(1-[Pi/(Mq)])/(q log[1+(i/q)]) where P = primary_loan ammount, i = interest rate, M = monthly payment and q = presumed # of payments per year (12 all the time) so in my 'sample' it would be something like P = 100,000, i= .1, M = 1400 and q = 12... if the math comes out right it should come up with 9.08 or 9.1 if you round (which i dont want to do) no clue how to do this in PHP.. any help appreciated... thanks..
-
http://www.w3schools.com/PHP/php_date.asp that'll give ya the gist on how to do it..
-
well if you have up to 10 different flags that can be used that is going to be difficult to do.... If I were you what I would do is create 10 php files 1.php, 2.php, 3.php, etc.... then maybe create a default.php in there too.... then to something like if (isset($flag)) { $flag++; include($flag.".php"); } that way it's one if file, that is including HTML code.... and if you go for having a default.php just in case the $flag isnt set if (!isset($flag)) { include('default.php'); } else { $flag++; include($flag.".php"); } reason why i use $flag++ is because since you're using probably $flag = 0 thru $flag = 9 (10 total) you'll always be behind one so in order to load the correct file (in the case of 0 load one at all) we need to jump that number up one... if the $flag++ doesnt work you can also do $flag = $flag + 1; or $flag = ($flag + 1); and it should work the same. my logic above was if there were only two variables like the original post made it sound.. isset($flag) ensures that $flag really does have a variable in it.... $flag == '' is my way of checking for NULL as I've had issues previously where checking for null so I switched to the double quote representation of null.
-
It shouldn't do that... When I used to mix my display with my logic I used that technique all the time. It could be that $flag is getting set to 0 somewhere... you might try: if (isset($flag) && $flag == '0' || $flag == '') { ?> html code <?php } else { ?> more html code <?php } ?> doing something like that might work if you want one code block to show if flag=0 and the other is if equals anything else. How are you obtaining the value for $flag?
-
<html> <head>......</head> <body>........som html code here... <?php if ($flag==0) { ?> some html code <?php } ?> ...some html code </body> </html> If the code you gave is correct minus the HTML in the 2 spots you erased out, your issue lies in 2 places. #1. if (flag == 0) { should be if ($flag == 0) { unless you have define('flag', 0); #2. before you can output html you either need to echo it out (not recommended) or close php then re-open after the html output is done such as in my example above. Hope it helps
-
I have this function completely written in my class file that I am working on. The point to this function is to be able to check the login of a user or administrator for either of the control panels associated with my site. It will check the session intime as well as the page / module referenced. Once it passes all those checks, it will check and ensure the emailaddress/password stored in the current session still holds true and the account is still active... if the account is still active it will update the lastActivity as well as update all of the session variables with what is currently in the database. What I am looking for is basically a look at the function, see if it looks good.. If there is any part to it that could create security holes for the site just off the login function itself... Usage: $q->validUser($_SESSION['user'], $_mod); <?php function validUser($sess, $p) { if ($sess['inTime'] == '' && $p != 'login' && $p != 'logout') { session_destroy(); $login = '0'; $_int = ''; return $login; } else if ($sess['inTime'] < time()-3600 && $p != 'login') { $sess['inTime'] = ''; session_destroy(); $this->check_login($sess, $p); } else { $this->user = $sess['emailAddress']; $this->pass = $sess['password']; $login = $this->sql_query("SELECT * FROM users WHERE emailAddress = '".$this->user."' AND password = '".$this->pass."' AND status = '1' LIMIT '1'"); if ($login = $this->sql_numrows($login) < 1) { $sess['inTime'] == ''; session_destroy(); $login = '0'; } else { // logged in, lets update the database for last_activity AND the session. $this->sql_query("UDATE users SET lastActivity = '".now()."' WHERE emailAddress = '".$this->user."'"); $login = $this->sql_query("SELECT * FROM users WHERE emailAddress = '".$this->user."' AND password = '".$this->pass."' AND status = '1' LIMIT '1'"); $login = mysql_fetch_assoc($login); foreach ($login as $key => $value) { $sess[$key] = $value; } $sess['inTime'] = time(); $login = '1'; } return $login; } } ?> That is the main function, sql_query and sql_numrows is: <?php function sql_query($query = "", $transaction = FALSE) { unset($this->query_result); if ($query != "") { $this->num_queries++; if ($transation == BEGIN_TRANSACTION && !$this->in_transation) { $result = mysql_query("BEGIN", $this->db_connect_id); if (!$result) { return false; } $this->in_transaction = TRUE; } $this->query_result = mysql_query($query, $this->db_connect_id); } else { if ($transaction == END_TRANSACTION && $this->in_transaction ) { $result = mysql_query("COMMIT", $this->db_connect_id); } } if ($this->query_result) { unset($this->row[$this->query_result]); unset($this->rowset[$this->query_result]); if ($transaction == END_TRANSACTION && $this->in_transaction ) { $this->in_transaction = FALSE; if (!mysql_query("COMMIT", $this->db_connect_id)) { mysql_query("ROLLBACK", $this->db_connect_id); return false; } } return $this->query_result; } else { if ($this->in_transaction ) { mysql_query("ROLLBACK", $this->db_connect_id); $this->in_transaction = FALSE; } return false; } } function sql_numrows($query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } return ($query_id) ? mysql_num_rows($query_id) : false; } ?> Any insight that can help to benefit these functions would be appreciated.
-
I need to use checkbox which looks like button
radar replied to ankit.pandeyc012's topic in HTML Help
you could create and up-state and a down-state for the same image... then run it through javascript ie: onclick="checkIt(); return false" <-- nearly always return false function checkIt() { if(document.getElementByID('checkbox').value == 'on') { document.getElementByID('checkbox').value = 'off'; document.getElementByID('image').style.class = 'image_up'; } else { document.getElementByID('checkbox').value = 'on'; document.getElementByID('image'].style.class = 'image_down'; } } image = the image checkbox = hidden field.