taith
Members-
Posts
1,514 -
Joined
-
Last visited
Everything posted by taith
-
Referencing a parent directory name ---- NEED HELP!!
taith replied to kevinn's topic in PHP Coding Help
if i knew what the $sitetitle function is... probably not... it'd take alot of code for a function to automatically switch from full path to relative path with 100% accuracy... twood be quicker to just change it manually from your database... i'm sure i could make one to switch from full to relative path... but tha'd prolly take a while lol -
Referencing a parent directory name ---- NEED HELP!!
taith replied to kevinn's topic in PHP Coding Help
$directory = "../../photos/thumbs/Set1/"; ../ and ./ are for relative path, not full -
Referencing a parent directory name ---- NEED HELP!!
taith replied to kevinn's topic in PHP Coding Help
./ <-- current directory ../ <-- parent directory -
for example... login.php [code] <? if(!empty($_POST)){ $username=$_POST[username]; $password=md5($_POST[password]); $result=mysql_query("SELECT * FROM users WHERE `username`='$username' AND `password`='$password' LIMIT 1"); $row=mysql_fetch_array($result); if(!empty($row)) $_SESSION[user]=$row; else die("Invalid Username/Password"); } ?> [/code]
-
not that i know of... but you can always [code] foreach($_POST as $k=>$v) echo '<input type=hidden name="'.$k.'" value="'.$v.'">'; [/code] but you would need to resubmit that form...
-
personally... if it were me, i like functions... i'd do it this way.... [code] function get_itemname($id){ if(!isset($allitemnames[$id])){ $result=mysql_query("SELECT * FROM items WHERE `id`='$id' LIMIT 1"); $row=mysql_fetch_array($result); $allitemnames[$id]=$row[name]; } return $allitemnames[$id]; } [/code] then wherever you want an item name... just... [code] echo get_itemname(1); echo get_itemname($page-1); echo get_itemname($page+1); [/code] or to that effect :-)
-
theres lots of tutorials about pagination here :-) not tested... but should work... [code] $topallowed=10; if(empty($_GET[page])) $topfile=0; else $topfile=$_GET[page]; $topallowed=$topallowed+$page; $result=mysql_query("SELECT * FROM table LIMIT $topfile, $topalllowed"); while($row=mysql_fetch_array($result)){ } echo '<a href="?page='.$page-1.'">prev</a>'; echo '<a href="?page='.$page+1.'">next</a>'; [/code] just for ideas...
-
yup! full url: [code] <? function get_url(){ if(!empty($_SERVER[QUERY_STRING])) return 'http://'.$_SERVER[SERVER_NAME].$_SERVER[PHP_SELF].'?'.$_SERVER[QUERY_STRING]; else return 'http://'.$_SERVER[SERVER_NAME].$_SERVER[PHP_SELF]; } echo get_url(); ?> [/code] just page: [code] <? echo $_SERVER['PHP_SELF']; ?> [/code]
-
it is not necessary... after a submit, $_POST is an array of all the values that were submited, nothing more... but if you want only values that are filled in... [code] <?php session_start(); foreach($_POST as $key => $var) if(!empty($_POST[$key])) $_SESSION[$key] = $var; ?> [/code]
-
true... isset() will check if the form was submitted, but !empty() is a much safer way of checking to see if a field has value...
-
yes... with forms, when you press submit, it sends every field as $_POST, as is, isset() will always return true, you'd want to use !empty()...
-
this is because of either a) flash is recording vector based art (php doesnt) b) flash works on a different color spectrom (hex, not rgb) or c) .jpg isnt translating the colours properly, try using .png(has more colour supports)
-
yup... you can do it that way too if you want... but it if you were wanting your page more automated... you'd prolly want somin like this.... [code] <? function form_autodropbox($to=array(),$selected="",$name=""){ if(!is_array($to)) return FALSE; $return .= '<select name="'.$name.'">'; foreach($to as $k => $v){ if($k==$selected) $return .= '<option selected value="'.$v.'">'.ucwords($k).'</option>'; else $return .= '<option value="'.$v.'">'.ucwords($k).'</option>'; } $return .= '</select>'; return $return; } $to[test]="asdf"; $to[test2]="asdf"; $to[test3]="asdf"; $to[test4]="asdf"; echo form_autodropbox($to,"test3",'test') ?> [/code]
-
yup! just set a value to the fields... for example... [code]<input type=text value="<?=$_POST[test]?>" name="test">[/code]
-
not tested, but should work :-) [code] <?php $now = getdate(time('G')); $hours = $now['hours']; $minutes = str_pad($now['minutes'], 2, "0", STR_PAD_LEFT); $seconds = str_pad($now['seconds'], 2, "0", STR_PAD_LEFT); echo $hours.":". $minutes.":".$seconds; ?> [/code]
-
php runs before javascript... you set up the js using php, then the js can configure from there.
-
.= just adds the string onto the end of a preexisting string [code] <? $str='hello'; $str.='world'; echo $str; #hello world ?> [/code]
-
still nothing.... [code] <style> .test{ height:200px; overflow:auto; width:10px; } </style> <table> <tr> <td class=test><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>v</td> </tr> </table> [/code]
-
include/require just crop the code from the target file, into the parent file. it doesnt make an iframe, you would need to do that seperatly.
-
[code]<? function form_autodropbox($to=array(),$selected="",$name=""){ if(!is_array($to)) return FALSE; $return .= '<select name="'.$name.'">'; foreach($to as $k => $v){ if($k==$selected) $return .= '<option selected value="'.$v.'">'.ucwords($k).'</option>'; else $return .= '<option value="'.$v.'">'.ucwords($k).'</option>'; } $return .= '</select>'; return $return; } echo form_autodropbox($to,$_POST[name],"name") ?>[/code]
-
the mysql_num_rows() shows you how many rows it returned... [code] $result = mysql_query("SELECT count(color) FROM mydb GROUP BY color AND catagory"); $row = mysql_fetch_array($result); print_r($row); #depends on your database which field they'll go into :-) [/code]
-
creating transparent images (that aren't speckled)
taith replied to michaellunsford's topic in PHP Coding Help
the reason why that happens... is because the picture background itself isnt exactly white, open it in gimp, color find, you'll find they are different colours... most likely. -
yes, include/require basically just "crop" the included page's source, into the parent file...
-
anyone wanna take a stab at why my overflow:auto never works? for example... [code] <style> .test{ height:300px; overflow:auto; } </style> <table> <tr> <td class=test><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>x</td> </tr> </table> [/code] and i... get no overflow... just me usual table :-( ???