taith
Members-
Posts
1,514 -
Joined
-
Last visited
Everything posted by taith
-
Please help review my datagrid for speed enhancements
taith replied to ThunderAI's topic in PHP Coding Help
secondly... [code] $adataselect[0] = ""; . . . [/code] is much faster set once [code] $adataselect = array('','','','',''); [/code] -
Please help review my datagrid for speed enhancements
taith replied to ThunderAI's topic in PHP Coding Help
firstly... the more comments in the page, the larger the file, the larger the file, the longer it takes to load it (serverside). -
not with .php ... the webpage is stored in the temp files, along with all the images, changing it on the database/server wont change them on the computer without reloading/ajax.
-
well... that depends... if the delete posts link is protected(admin or whatnot) $_GET[] is easier and faster... if they are open to anybody... use $_POST[] as you cant change the active sourcecode and much harder to hack...
-
[code]$string='text text text text<br>'; echo ucfirst($string); echo ucwords($string);[/code]
-
something to that effect maybe? [code] <?php if($handle = opendir('.')){ while (false !== ($file = readdir($handle))){ if($file != "." && $file != ".."){ $images[]=$file; } } closedir($handle); } $current=$_GET[image]; if(empty($current)) $current=1; $prev=$images[$current-1]; $image='<img src="gallery/'.$images[current].'">'; $next=$images[$current+1]; ?> [/code]
-
you can use that wherever you likes the only things that need to be prior to any output are things that are not sent along with the headers(cookies, session_start, print, etc)
-
[code] $name = "test"; if(is_nan($name)) echo "GOOD"; else echo "BAD"; [/code]
-
found something! http://us3.php.net/manual/en/function.printer-set-option.php [code] printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_A4); [/code] assuming your using a link to print the page, that might help, if your using file print, probly not...
-
Need a small amount of help from a smart php person please.
taith replied to 11Tami's topic in PHP Coding Help
for example... [code]<?php $link = mysql_connect('host', 'username', 'password'); $db_selected = mysql_select_db('database', $link); $result = mysql_query("SELECT names FROM users WHERE `names`='bobby'"); while ($row = mysql_fetch_array($result)){ print "<p>$row[names]</p>"; } ?>[/code] -
[code] <?php include('header.inc'); $page = $_GET['url']; if(empty($page)) $page = 404_notfoud include($page.'.php'); include('footer'); ?>[/code]
-
you had pc... should be site [code] <?php include("sql/conn.php"); mysql_select_db($db_name) or die( "Unable to select database"); $scrollresult=mysql_query("SELECT scroll FROM site"); $scroll=mysql_result($scrollresult,0,"scroll"); echo "currently set to $scroll<br/><br/>"; if($scroll=="yes") $newscroll="no"; else $newscroll="yes"; echo "now it's set to $newscroll<br/><br/>"; // here is where it dies $result=mysql_query("update site set `scroll`='$newscroll'") or die(mysql_error()); ?> [/code]
-
heres one i just found... [url=http://www.analysespider.com/geo-targeting/geo-targeting.html]http://www.analysespider.com/geo-targeting/geo-targeting.html[/url]
-
scan a folder and get names of all folders within that folder?
taith replied to ztealmax's topic in PHP Coding Help
[code]$files = glob('*'); foreach($files as $file){ if(strpos(".",$file,1)==false) echo $file; }[/code] -
sorry... that wasnt tested... this should work... [code] <? error_reporting(E_ALL ^ E_NOTICE); mysql_connect("localhost","nancy","blabla"); mysql_select_db("nancy"); if(!isset($_GET["cmd"])){ $result = mysql_query("select * from news order by id"); while($r=mysql_fetch_array($result)){ echo '<p>endre nyheter:</p><a href="edit.php?cmd=edit&id='.$r[title].'">'.$r[id].'</a><br/>'; } }else{ if(!isset($_POST["submit"])){ $result = mysql_query("SELECT * FROM news WHERE `id`='$_GET[id]'"); $myrow = mysql_fetch_array($result); ?> <form action="edit.php?cmd=edit" method="post"> <table> <tr> <td>tittel:</td> <td><input type="text" name="title" value="<?php echo $myrow["title"] ?>" size='40'></td> </tr> <tr> <td>forfatter:</td> <td><input type="text" name="author" value="<?php echo $myrow["author"] ?>" size='40'></td> </tr> <tr> <td>tekst:</td> <td><textarea name="news" cols='30' rows='5'><? echo $myrow["news"] ?></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="endre"></td> </tr> </table> </form> <? }elseif($_POST["submit"]){ $result = mysql_query("UPDATE news SET title='$_POST[title]', `news`='$_POST[news]', `author`='$_POST[author]' WHERE id=$id"); echo "query finished."; } } ?> [/code]
-
try that [code] <? error_reporting(E_ALL ^ E_NOTICE); mysql_connect("localhost","nancy","blabla"); mysql_select_db("nancy"); if(!isset($_GET["cmd"])){ $result = mysql_query("select * from news order by id"); while($r=mysql_fetch_array($result)){ echo "<p>endre nyheter:</p>"; echo "<a href='edit.php?cmd=edit&id=$r["title"]'>$r["id"]</a><br/>"; } }else{ if(!isset($_POST["submit"])){ $result = mysql_query("SELECT * FROM news WHERE id=$_GET['id']"); $myrow = mysql_fetch_array($result); ?> <form action="edit.php?cmd=edit" method="post"> <table> <tr> <td>tittel:</td> <td><input type="text" name="title" value="<?php echo $myrow["title"] ?>" size='40'></td> </tr> <tr> <td>forfatter:</td> <td><input type="text" name="author" value="<?php echo $myrow["author"] ?>" size='40'></td> </tr> <tr> <td>tekst:</td> <td><textarea name="news" cols='30' rows='5'><? echo $myrow["news"] ?></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="endre"></td> </tr> </table> </form> <? }elseif($_POST["submit"]){ $result = mysql_query("UPDATE news SET title='$_POST["title"]', `news`='$_POST["news"]', `author`='$_POST["author"]' WHERE id=$id"); echo "query finished."; } } ?> [/code]
-
also, your missing the time field [code] $result=mysql_error("INSERT INTO news (title,message,who,date,time) VALUES ('$title', '$message', '$who', '$date')"); [/code]
-
just as a forenote... you might want to remove the user/password from submitted code ;-)
-
scan a folder and get names of all folders within that folder?
taith replied to ztealmax's topic in PHP Coding Help
glob() is SOO much faster [code] $files=glob('images/*'); echo '<select>'; foreach($files as file) echo '<option>'.$file.'</option>'; echo '</select>'; [/code] you dont need an absolute path either -
no... php doesnt do that... it has access only to the headers... not the browser specifics that javascript can...
-
that'll give you a string of random letters to any length you want [code] function randomkeys($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for($i=0;$i<$length;$i++) $key .= $pattern{rand(0,62)}; return $key; } $x=randomkeys(1); echo $x; [/code]
-
1 + 2 = 3 (add up of infinite text counter files)
taith replied to ted_chou12's topic in PHP Coding Help
yes... it should... -
perfect :-) thanks :-D
-
exactly, when i use distinct with path alone, it gives me one record... when i use it with id, it gives me all of them.
-
when i take the id out, it works perfectly, but i need both of those columns, i need distinct path, and all id's associated with it. [code] $result=mysql_query("SELECT DISTINCT path, id FROM im_files WHERE (`uid1`='$id' AND `uid2`='$key') OR (`uid2`='$id' AND `uid1`='$key') ORDER BY id") or die(mysql_error()); [/code]