taith
Members-
Posts
1,514 -
Joined
-
Last visited
Everything posted by taith
-
take a look at http://us2.php.net/manual/en/function.number-format.php that'd help ya out there :-)
-
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]
-
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]
-
Does anyone know how to make users and accounts on a website?
taith replied to Cyber1AS's topic in PHP Coding Help
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... -
<?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; } ?>
-
$this=true; if($this) echo true; #$this==true if(!$this) echo false; #$this==false
-
[code]<? function get_referrer(){ if(!$ref=@$HTTP_REFERER) $ref=$_SERVER['HTTP_REFERER']; return $ref; } ?>[/code]
-
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...
-
[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 :-)
-
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.
-
[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]
-
$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... ;-)
-
glob() is MUCH easier for this type of work... [code] <? $files = array_merge(glob("*.php"),glob("*.gif")); print_r($files); ?> [/code]
-
dont use the preceding / [code] <?php require("includes/footer_links.php"); ?> [/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; } ?>
-
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
-
[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
-
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.
-
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
-
[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]
-
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.
-
Seriously wierd- Goes directly to empty field echo
taith replied to HoTDaWg's topic in PHP Coding Help
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 :-) -
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...