Jump to content

radar

Members
  • Posts

    645
  • Joined

  • Last visited

Everything posted by radar

  1. 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..
  2. 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.
  3. is it varchar, but which numerical datatype to use? decimal and int both seem to remove the decimal points.
  4. 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?
  5. 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?
  6. beautiful. thanks xyph... saves me a ton of hassle within the next day or two... I really appreciate it.
  7. 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
  8. 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!
  9. 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..
  10. http://www.w3schools.com/PHP/php_date.asp that'll give ya the gist on how to do it..
  11. 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.
  12. 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?
  13. <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
  14. 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.
  15. 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.
  16. Your form should always have a name. I've created a page (for giggles) on my local server that all it does is log people in, it has 13 login forms and all 13 work.... Try adding a name like frmLoginTop and frmLoginBottom and see what happens then... your submit button should also have a name... ie: <input type="submit" name="button" id="button" value="Submit">. I have sometimes run into weird issues when i try to use caps for everything in HTML like mysql SELECT * FROM blah WHERE d = BLEH or the like. So turn down the caps and see where that takes you from there. also code on the html other than a single form would be helpful.
  17. i'm usually not the nicest person when it comes to website critiques. Your design, while like you said arent the best, they are solid and I actually liked them. the only bad things I saw throughout your site, and most people wouldnt have seen it. is you have inline styles, you have css defined in your main document instead of an external document... and you have a boatload of javascript at the end of the file... make all those brought in via external files and it'll be a pretty solid foundation I think in terms of SEO stuff goes.
  18. Not to be rude here, but I think you've put the p where the c should be and vice versa.. thus making the site: http://toxicpets.co.uk/ now if this is the case, and again i'm not trying to be rude, but i would hit CTRL + A and then hit delete and get rid of this site. There is a lack of design, lack of thought even just on the main page. The graphics that are there are absurdly horrendous. All and all, IMHO toxicpets.co.uk is a blatant waste of space on the internet. The idea behind the website could very well be something that people would use (sounds like neopets.com remake?). In which case great keep with it, but put it on hold, put some real thought behind it and come up with a real user-friendly, eye-catching, memory-burning design and content that people just can't help but spread.
  19. I happen to agree with thewoolymammoth on the text over the center of your banner (The Ideal Plumber Serving the Los Angeles Area) -- this should be removed. Instead of displaying the email address on the contact page, i'd definately opt for a contact form with some capcha for protection. Displaying the email, means spam is on its way! On the photos page, the spry element that you used directly from Dreamweaver CS5 is horrid (ive used it once for about 3 days)... It is choppy, not reliable, the information that you can add to the image is in a hard to see location... not easily made database driven... you'd be better off finding a different javascript gallery... something that'll take your list of images (you'll need the large images and thumbnails just like the spry version you're using) and display them similar but without the automatic animation.. Get rid of the Home link in navigation bar, instead make the header image link to the root domain... it's a hidden home link, but trust me people find it. Think of your SEO... With your titles all the same on every page, you won't rank well in SEO... the meta-description, keywords, and of course page content all needs to be different on each page as well (some developers skip the keywords in meta-tags all together, but I personally still use them). Get rid of your inline image height-width settings, upload the images the size they need to be displayed at and just call the image. Remember alt tags on all images not just some, but all... The most top left handed images alt tag should be your main keyword.. Currently it is 'Ideal Plumbing' but when I need plumbing work, i'm not searching for Ideal Plumbing, I am searching for Plumbers Salt Lake City or something like that.... again your SEO... get your javascript out of the pages, include it through an external JS file. While the ads will potentially drive more clients away (i hate ads) they're not intrusive too much so you could get away with them. Remember that often times (no matter what business it is), a website can be your first impression to your customers. With this being said, having a design specifically that appears to either be a sub-par free template, or one from a do-it-yourself box that was purchased from office max can deter customers... Although having just done a search for Plumbers North Hollywood and looking at the 2nd, 3rd and 4th place sites and their current pagerank, seo practices, designs, etc.. it actually wouldn't be too difficult (even using the design you have now) to get ranked within the top 5 for the keyword Plumbers North Hollywood. Ultimately what I think it is going to take, is a little thinking on your side and for you to decide whether the do-it-yourself type style is good enough for a business as strong as 'Ideal Plumbing'. If it is, then continue on where you're going. If not, then it'd be in your best interest to contact a few design and development companies (I can name a few if you wish), and recieve quotes from them on building your site from scratch. Whether or not this is financially viable for you right now isn't the point of getting the quotes. The point of getting the quotes is to potentially see what type of a price-point you'd be looking at for the site design, programming and logo design for the plumbing business website which would then give you ball-park figures to save up to (even 50 a month in savings toward the website). Welp, I think I have rambled on enough on you for today. Hope any part of what I've said helps you and your website in the slightest.
  20. Alright so it's been a little while, but i've put this all together and it works... So as promised, here I am posting my resolution just in case others face this sometime too.. <?php function getItems($dist, $start, $limit, $post="undead") { if($post != "undead") { // we have post data, lets filter it somehow. if ($_POST['levels'] != '') { // levels were selected, lets filter them. foreach ($_POST['levels'] as $t){ if ($levels == '') { $levels = ' FIND_IN_SET('.$t.', a.levels)'; } else { $levels .= ' OR FIND_IN_SET('.$t.', a.levels)'; } } } if ($post['sport'] != '') { // sports were selected, lets filter them. foreach($_POST['sport'] as $t) { if ($sports == '') { $sports = "'".$t."'"; } else { $sports .= ",'".$t."'"; } } if ($levels == '') { $sport = " a.sport IN (".$sports.")"; } else { $sport = " AND a.sport IN (".$sports.")"; } } if ($post['status'] != '') { // status was selected. if ($post['status'] != "2") { if($sport == '' && $levels == '') { $status = " a.is_visible = ".$post['status']; } else { $status = " AND a.is_visible = ".$post['status']; } } } if ($post['category'] != '') { if($sport == '' && $levels == '' && $status == '') { $category = " a.category = ".$post['category']." AND "; } else { $category = " AND a.category = ".$post['category']; } } if ($levels != '' || $sport != '' || $status != '' || $category != '') { $and = " AND"; } } $sql = "SELECT SQL_CALC_FOUND_ROWS a.ItemID, a.spec, a.description, a.sport, a.category, a.price, a.unit_qty, a.is_visible, a.AdminID, b.name, b.ItemID as catID, c.Name as nameSport, c.ItemID as sportID FROM purchase_request_category_item as a LEFT JOIN purchase_request_category as b ON b.itemID = a.category LEFT JOIN ro_school_sports as c ON c.ItemID = a.sport WHERE".$levels.$sport.$status.$category.$and." a.AdminID = '".$dist."' GROUP BY a.ItemID, b.name, c.Name ORDER BY a.ItemID DESC LIMIT ".$start.",".$limit; $data = mysql_query($sql); $cnt = mysql_num_rows($data); $_query = "SELECT FOUND_ROWS() as total"; $_result = mysql_query($_query); $_row = mysql_fetch_array($_result, MYSQL_ASSOC); Paginate::setTotal($_row['total']); if ($cnt == '' || $cnt == '0') { $data = '<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td>There are 0 Items listed for your district. Please add some by clicking on \'add new\' up top.</td></tr></table>'; } else { $data = sql_md_array($data, $cnt); } return $data; } ?> I tried using the implode at the beginning, and it just didn't work right so I went through the sports using a foreach formatting them in the correct way. Only issue I had was that in my main php file, I sent $_POST over which is called in this file by $post -- but on the levels, it would never read it, so I had to use $_POST... So with the set, formatting a multiple select into multiple FIND_IN_SET works... Since this is a dynamic query, I had to add in the lines to check if any of the items were not empty ($levels, $sports, $status, $category) and if they are empty make $and = '' otherwise $and = " AND"; this way my last where clause adminID works instead of throwing an error... it's sloppy i'm sure, but hey it works! I'll figure out a better way to clean it up later.
  21. Look into using prototype.js then on your form button on the sidebar you'd put in: onclick="displayPrice("enter the form id here (id not name)"); return false" return false is needed these days for IE which for some reason doesn't use the old rulings of whether an onclick was called, and it always recalls the page... then in a javascript file (not the prototype.js) you would have something like: function displayPrice(formID) { var myRand = parseInt(Math.random()*99999999); var srcs = "figureoutprice.php?ints="+myRand; // adding myRand here beats browser cache. change the url to whatever, just remember to keep adding int(i use ints)="+myRand to it, of course int, ints, dongknocker, doesnt matter it does the same thing and the end user never actually sees it. var pars = Form.serialize(formID); var myAjax = new Ajax.Request ( srcs, { method: "post", parameters: pars, onComplete: function(OriginalRequest) { // originalRequest.responseTest is used here.... document.getElementByID('price').innerHTML = originalRequest.responseText; } }); } this shows there is an element ID with the name of price, so you would have the html code: $<span id="price"></span> wrapped around wherever on the page you want your price to be... keep in mind that having more than one price results in only 1 getting changed.. each of them need to have their own name, and also need to be coded in the js file... enjoy
  22. An easy way would be to use prototype.js style ajax, to send the username and password back to a login script.... So you'd continue to have what you currently have but you'd add in the prototype workings and add in: function login(formID) { <-- needed.. i'd include a MyRand to beat browser caching... var MyRand = parseInt(Math.random()*99999999); then you'd add var srcs = "login.php"; then you'd serialize the form objects: var pars = Form.serialize(formID); then you'd simply add var myAjax = new Ajax.Request ( srcs, { method: "post", parameters: pars, onComplete: function(originalRequest) { // do something here } }); } this would take your form objects, back to php where you can handle it however you want.... while still utilizing the code you currently have to use the .htaccess stuff. hope it gets you started at least
  23. The only thing I can see (without actually opening up DW for my syntax highlighting), is that your script tag should have at least the minmal language="javascript" inside of it. Of course since I'm seeing a missing ) and } i'm guessing that this code example isnt the full code of what using, which makes it a little hard to diagnose an issue. Does IE show you any javascript errors in the status bar? if so what do they say, this could be a fairly easy way to diagnose it.
  24. The way I do my joins on 2 or more tables using left join is like this, perhaps it'll help you as well. $sql = "SELECT SQL_CALC_FOUND_ROWS cust.id, cust.f_name, cust.l_name, cust.email, cust.password, cust.status, COUNT( o.id ) AS orders_cnt, COUNT( d.id ) AS deals_cnt, d.c_id as dc_id, o.c_id FROM customers AS cust LEFT JOIN orders AS o ON o.c_id = cust.id LEFT JOIN deals AS d ON d.c_id = cust.id GROUP BY o.c_id, dc_id, cust.id ORDER BY cust.l_name LIMIT ". Paginate::getCurrentIndex().",".Paginate::getLimit();
  25. finding out the specific model number, unknown.... this might at least get you closer: http://mobiforge.com/developing/story/lightweight-device-detection-php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.