Jump to content

taith

Members
  • Posts

    1,514
  • Joined

  • Last visited

Everything posted by taith

  1. i think your looking for implode() [code] $string=implode(", ",$array); [/code]
  2. $x->$y is for classes $x[$y] is an array, much more commonly used for databases(mysql_fetch_array())
  3. http://www.phpfreaks.com/forums/index.php/topic,115581.0.html
  4. $string='House'; echo $string{0}; #H
  5. however, i do suggest that you unset($_POST[]) the vars that you dont want in the query, before the foreach()
  6. i jest not... $_POST holds all the fields from your previous form... so... why not use it as an array and build your query that way?
  7. easier way [code] <? session_start(); $_SESSION=array(); header('http://www.giftfromgodcomputerfoundation.org'); exit; ?> [/code] fyi: sessions must be started before its destroyed :-)
  8. yup... thousands of if()elesif()'s... or 1 foreach()... ;-) [code] $name = $_POST['name']; $pet = $_POST['pet']; foreach($_POST as $k=>$v) if(!empty($_POST[$k]))$query.=" && `$k`='%$v%'"; if(empty($query)) die("You must enter some fields"); $user_query = "SELECT * FROM mytable WHERE name='$name' $query"; $result = mysql_query($user_query) or die ("no can do"); [/code] or something to that effect :-)
  9. ... no... you really did... [code] if(trim($mod_data[i]) [/code]
  10. $mod_data[i] -->  $mod_data[$i] # you forgot the $'s
  11. [code] if(!empty($_POST['pet'])){ $name = $_POST['name']; $pet = $_POST['pet']; $user_query = "SELECT * FROM mytable WHERE name='$name' && pet='%$pet%' "; $result = mysql_query($user_query) or die ("no can do"); }else echo 'You must enter a specific search.'; [/code]
  12. no... &&/|| works just as well as AND/OR
  13. yes it would :-)but if you add a simple if(!empty($_POST[pet])){ rest of code in here }
  14. mysql does have a wildcard operator... % [code] $name = $_POST['name']; $pet = $_POST['pet']; $user_query = "SELECT * FROM mytable WHERE name='$name' && pet='%$pet%' "; $result = mysql_query($user_query) or die ("no can do"); [/code] that much being said... if $pet="bear" it'll find "polar bear", "bear", "grizzley bear", etc... but if you $pet="polar bear" it'll find "polar bear", and not bear, or grizzley bear
  15. not by the way that your probably thinking... php is finished processing by the time it hits the browser... however... php can echo out javascript... so you can automate many javascript functions through php... for example... [code]<? function status_decrypt($text, $link, $status){ global $statusdecrypt, $head; if(!isset($statusdecrypt)){   $statusdecrypt=1;   $head .=' <SCRIPT LANGUAGE="JavaScript"><!--';   $head .='var data="0123456789";';   $head .='var done=1;';   $head .='function statusIn(text){';   $head .=' decrypt(text,2,1);';   $head .='}';   $head .='function statusOut(){';   $head .=' self.status = \'\';';   $head .=' done=1;';   $head .='}';   $head .='function decrypt(text, max, delay){';   $head .=' if(done){';   $head .='  done=0;';   $head .='  decrypt_helper(text, max, delay, 0, max);';   $head .=' }';   $head .='}';   $head .='function decrypt_helper(text, runs_left, delay, charvar, max){';   $head .=' if(!done){';   $head .='  runs_left = runs_left - 1;';   $head .='  var status = text.substring(0, charvar);';   $head .='  for(var current_char = charvar; current_char < text.length; current_char++){';   $head .='  status += data.charAt(Math.round(Math.random()*data.length));';   $head .='  }';   $head .='  window.status=status;';   $head .='  var rerun = "decrypt_helper(\'" + text + "\'," + runs_left + "," + delay + "," + charvar + "," + max + ");"';   $head .='  var new_char = charvar + 1;';   $head .='  var next_char="decrypt_helper(\'" + text + "\'," + max + "," + delay + "," + new_char + "," + max + ");"';   $head .='  if(runs_left > 0){';   $head .='  setTimeout(rerun, delay);';   $head .='  }else{';   $head .='  if(charvar < text.length){';   $head .='    setTimeout(next_char, Math.round(delay*(charvar+3)/(charvar+1)));';   $head .='  }else{';   $head .='    done=1;';   $head .='  }';   $head .='  }';   $head .=' }';   $head .='}';   $head .='--></script>'; } return '<a href="'.$link.'" onMouseOver="statusIn("'.$status.'");return true;" onMouseOut="statusOut();">'.$text.'</a>'; } ?>[/code] or to that effect :-)
  16. no... sessions are tied to the browser itself... so if the user closes his browser, the session dies... however if your using a browser with tabs, closing a tab, will not kill the session.
  17. 30 min from the last session_start(); which should be at the top of all your doccuments
  18. [code] <? session_start(); ?> <style type="text/css"> a:link {   color:#0099FF} a:visited{   color:#CC99FF} font{   color:#FFFFFF} p{ color:#FFFFFF} </style> <font color = "White"></font> <table width="884" height="185" border="0" align = "center">   <tr align = "center">     <td width="445" height="74" rowspan="2"><img src="Logo.jpg" width="406" height="104"></td>     <td height="122" colspan="3"> <?php if(isset($_SESSION['in'])){ if($_SESSION['in'] == 1) include("Logoutlink.php"); else include("Login.php"); } ?> </td>   </tr>   <tr bordercolor = "white">     <td width="57" height="21"><div align="center"><a href="index.php">Home</a></div></td>     <td width="68"><div align="center"><a href="about.php">About</a></div></td>     <td width="98"><div align="center"><a href="MyAccount.php">My Account</a></div></td>   </tr> </table> [/code]
  19. [code] $result=msyql_query("SELECT MAX(id) FROM invoices"); $row=mysql_fetch_array(); $newid=$row['MAX(id)']+1; [/code]
  20. then you'd want to specify height/width to them all :-P
  21. try somin like this maybe... it'll cut off everything after the last . instead of off of a number or what all else :-) [code]<? function get_filename($filepath){ return substr($filepath, 0, strpos($filepath, strrchr($filepath, "."))); } ?>[/code]
  22. in realtime? or just transfering the information over?
  23. if your talking about copying files, it would simply be a copy/paste... if your talking aobut the database, you'd want to backup the database, put it into a array, then connect to your new one, and import it there...
×
×
  • 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.