Jump to content

taith

Members
  • Posts

    1,514
  • Joined

  • Last visited

Everything posted by taith

  1. take a look at http://us2.php.net/manual/en/function.number-format.php that'd help ya out there :-)
  2. not tested... but this should work... [code] <style> table{border:black 1px solid;} .finished{background:red;} </style> <? $total=100; $finished=21; echo '<table><tr>'; for($i=0;$i<=$total;$i++){ if($finished>$i) echo '<td class=finished></td>' else echo '<td class=unfinished></td>' } echo '</tr></table>'; ?> [/code]
  3. if you want more, you'll need to say how you got your database set up... [code] $result=mysql_query("SELECT * FROM table"); while($row=mysql_fetch_array($result)){ $total=$total+$row[cost]; } [/code]
  4. wow... um... vague... basically... you want a table in your database for users with a spot for a id/username/password/etc. then you have on your page a spot to login, which then pulls up the account, and saves the account in a session...
  5. <?php function timeago($timestamp){ $current_time = time(); $difference = $current_time - $timestamp; $periods = array("minute", "hour", "day", "week", "month", "year", "decade"); $lengths = array(60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for($val = sizeof($lengths) - 1; ($val >= 0) && (($number = $difference / $lengths[$val]) < 1); $val--); if($val < 0) $val = 0; $new_time = $current_time - ($difference % $lengths[$val]); $number = floor($number); if($number != 1) $periods[$val].= "s"; $text = sprintf("%d %s ", $number, $periods[$val]);    if(($val >= 1) && (($current_time - $new_time) > 0)) $text .= timeago($new_time); return $text; } ?>
  6. $this=true; if($this) echo true; #$this==true if(!$this) echo false; #$this==false
  7. [code]<? function get_referrer(){ if(!$ref=@$HTTP_REFERER) $ref=$_SERVER['HTTP_REFERER']; return $ref; } ?>[/code]
  8. you dont need to specify the "orlandofull." just "ORDER BY Club" you only need to specify the table name if your accessing 2 tables at once...
  9. [code]<? function filter_charlimit($string, $length="50"){ if(strlen($string)<$length) return $string; else return trim(substr($string, 0, $length)).'...'; } ?>[/code] there ya go... that one counts chars, not words :-)
  10. oh... ok :-) basically... it counts how many words are in, the string, if its not greater then the $length, it returns it as is, if it is greater, it cuts off after the last allowed word and adds "..." and returns that.
  11. [code] <? function filter_wordlimit($string, $length=50, $ellipsis='...'){ return count($words = preg_split('/\s+/', ltrim($string), $length + 1)) > $length ? rtrim(substr($string, 0, strlen($string) - strlen(end($words)))) . $ellipsis : $string; } echo filter_wordlimit('I can put a really long paragraph in here if i want to, and it will trim it down to 20 words long','20'); ?> [/code]
  12. $date='2006-03-07'; $date=str_replace("-", "", "$date"); echo $date; #20060307 edit: just as a note its MUCH easier to have date(z) in the database, expire, remove that way... ;-)
  13. glob() is MUCH easier for this type of work... [code] <? $files = array_merge(glob("*.php"),glob("*.gif")); print_r($files); ?> [/code]
  14. dont use the preceding / [code] <?php require("includes/footer_links.php"); ?> [/code]
  15. <? function filter_wordlimit($string, $length=50, $ellipsis='...'){ return count($words = preg_split('/\s+/', ltrim($string), $length + 1)) > $length ? rtrim(substr($string, 0, strlen($string) - strlen(end($words)))) . $ellipsis : $string; } ?>
  16. what i did and suggest. find yourself either a book or some tutorials(www.tizag.com) and get yourself some php enabled webspace, while reading the book, [u]try it[/u], when you think you get the idea, move on to the next section
  17. [code]<?php session_start(); foreach($_POST as $key => $var){ if(!empty($_SESSION[$var])) $_SESSION[$key] = $var; else $empty[]=$key; } ?>[/code] there ya got an array of all the empty $_POST's
  18. code? basically... what you want to do, is when its coming out of the file, you want to $var=addslashes($var); this protects it from all them characters interfering with the code then when displaying, you echo stripslashes($var); this takes all the slashes out, so you dont have to see them.
  19. taith

    ID in URL

    lol... no its not classes... lol switch is simple... heres an example [code] switch(rand(0,5)){ default:   echo 'if rand(0,5) doesnt == 1 or 4'; break; case "1":   echo 'rand(0,5)==1<br>'; break; case "4":   echo 'rand(0,5)==4<br>'; break; case "1": case "4":   echo 'rand(0,5)==1 or 4'; break; } [/code] switch() its MUCH faster then if()elseif() ing anything more then 1ce
  20. also check out www.tizag.com its got simple mysql/php/etc tutorials galore
  21. taith

    ID in URL

    [code]<?php switch($_GET[op]){ default:   echo '<a href="currentpage.php?id='.$id.'&op=delete">Delete me</a>'; break; case "delete":   mysql_query("DELETE FROM user WHERE `id`='$_GET[id]'") or die(mysql_error()); break; } ?>[/code]
  22. yes. most pages(microsoft, google, etc) copyright their images/information so it is illegal to even save them onto your computer. writing a biography, may help cool tempers, but it doesnt make it any less illegal. other pages copyright their images for private use, as in you can save them, but cannot put them online anywhere else. and other pages dont copyright their images atall, in which they are free to save, and use again anywhere you likes.
  23. get the session_start(); out of the function... always put it at the top of your parent page. and nowhere else. also, on your queries... put mysql_query() or die(mysql_error()); that'll tell ya exactly whats wrong with your query :-)
  24. a) this is a help page, you break it, we help you fix it lol b) if you were wanting someone to build it, post on the freelancing page c) you'll be lucky to find a programmer to build a large page for free...
  25. your php is working perfectly, your taking the form information, pulling it out of the database, but your not using it anywhere... how do you want it to work? you still need to access the information [code] while($row=mysql_fetch_array($result)){ } [/code] http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php theres a good tutorial site you might find helpful...
×
×
  • 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.