Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. yer problem lies with this line if ($child[0] == '.') {continue;} it shud compare against . .. if ($child == '.' || $child== '..') {continue;} otherwise any file with . as first chatacter will be ignored, and cause it to fail
  2. Here ya goes <?php // Get Todays Date list($m,$d,$y)=explode('/','10/17/2008'); //Generate random days schedule $sch=array(); for($counter=intval(floor($d/2));$counter>0;$counter--) { do { $sd = rand(1,$d); } while (array_search($sd,$sch)!=false); $sch[]=$sd; } //Initialize our array $dim=array_fill(1,$d,false); // Fill in our Schedule foreach ($sch as $val) $dim[$val]=true; // Show our Schedule foreach ($dim as $day) echo date('m/d/Y',mktime(0,0,0,$m,$day,$y)). '-' . ($day?'Closed':'Open') ."<BR>\n"; Hope it makes sense to u, a simple array with marks if yer open/closed for those days
  3. I disagree, Flat files can be fast and efficient means of storing info. Caches are usually based on flat file designs, as well as the popular subset of SQL known as SQLite. And hands down it beats MySQL. So YES, ya can move some of the data into a flat file schema and improve performance. But as with any DB, Design for optimized usage.
  4. The php if statement bypasses the javascript if statement. notice that the javascript redirects the user to your script if a hieght width isn't sent. PHP Logic Do we have height width parameters Yes, Display some Info No, Use Javascript to detect parameters and reload page with parameters
  5. UPDATE tablename (field1,field2,field3) VALUES ('value1','value2','value3') WHERE Condition wud take too long to rewrite all those queries, but if u take the example above, shud help u make the query.
  6. Its cuz u use mysql_fetch_array in and before the loop. remove it from before the loop. otherwise the first record is always lost $query_users = "SELECT id, username FROM users"; $users = mysql_query($query_users) OR die ('Cannot retrieve a list of users.'); //$row_users = mysql_fetch_array($users); <select name="user"> <?php while($row_users = mysql_fetch_array($users)) { print '<option value="' . $row_users['id'] . '">' . $row_users['username'] . '</option>'; } ?> </select>
  7. Found a simple counter in this forum under tutorials //This is the code for the counter it makes a txt file named counter and it stores // the amount of times its been viewed $TextFile = "counter.txt"; $Count = 0+trim(file_get_contents($TextFile)); $Count++; file_put_contents($TextFile,$Count); very simple, and to the point
  8. Use a counter tracker or consider using time(). Counter u shud find a number of tutorials on
  9. My thoughts exactly, when i seen this post.
  10. Its not a mysql question. he needs the days in month for an average calculation. AverageDaysInClass = DaysInClass / DaysInMonth.
  11. julian calander functions would prolly be more useful here. but if ya dun have access to those functions (add on to php) u can either build yer own julian calander functions or play with strtotime <?php header('Content-type: text/plain'); function daysinmonth($date) { $d1=strtotime($date); echo date("Y-m-d",$d1)."\n"; $d2=strtotime(date("Y-m-01",$d1)); // First day of Month echo date("Y-m-d",$d2)."\n"; $d3=strtotime("+1 Month -1 Day",$d2); echo date("Y-m-d",$d3)."\n"; return intval(date("d",$d3)); } echo daysinmonth("2007-12-31") ?>
  12. Haku's method of storing language into a cookie, is great for a site that allows everyone to browse the site. if it's a members only site, u may consider storing this in the user db instead. or have a variation of both, if the site allows users specific pages, and members others. Good luck with the site
  13. Yes, thats the type of system I developed initially as well. but u also shud add in a string identifier as well as integer lookups will be a lot faster TABLE LangStrings lang integer /language identifier strid integer /string identifier string text /the actual text with lang and string being a multi-primary key. This can be used in yer editor to find a specific string id, and return all the language results. so u can use the same string across pages. The cache function isnt hard to make, with ob_start/ob_get_contents/ob_end_clean functions. all u do is check the existance of the file first, if it exists display the content, otherwise generate the content and save the output if(file_exists($language."_"$page.".html")) $content=file_get_contents($language."_"$page.".html"); else { ob_start(); // Display page code here $content=ob_get_contents(); ob_end_clean(); file_put_contents($language."_".$page.".html"); } echo $content;
  14. PHP is server side only. u want something to display on client side, while php is still working, consider using javascript/ajax.
  15. I thought about that too. static pages are a pain to maintain. db pages require extra time to display. Best Solution: Caching use a db solution with a cache feature, that adds the language to the name.
  16. Yep thats the way a lot of ppl do it. keep a maintained list of banned email hosts. so u may want to use a site that lists free email hosts, and extract the hostnames or domain names provided by that host.
  17. question is HOW do u keep from getting duplicates? $dupe_araay=$listarray; $rand_keys=array(); srand((double)microtime()*1000000); for($i=0;$i<5;$i++) { $avail_keys=array_keys($dupearray); $randval = rand(0,count($linkarray)-1); $rand_keys[]=$avail_keys[$randval]; unset($dupearray[$avail_keys[$randval]]); } unset($dupearray); [code] here we make a copy of the list, and we grab 5 random keys, removing the key from the list. so u are assured no dupes are in the list. than just proceed to display the list with a foreach loop [/code]
  18. echo array_search("c",$arr);
  19. Use the date function with z Parameter. the z Parameter returns the day of year. now question is, how use a limiter to select a set number of images. quick coding sample <?php header('Content-type: text/plain'); $ads=array('ad01','ad02','ad03','ad04','ad05','ad06','ad07','ad08'); $today=intval(date('z')); $num_ads=count($ads); $i=0; while($i++<10) { $todays_ad=$ads[($today % $num_ads)]; echo "Todays Ad: $todays_ad\n"; $today++; } ?>
  20. than u wud want to go into the SQL forum section. if u have a table like (Yes I know this isnt SQL syntax but shud give u a general idea of the table setup. id integer start_date date end_date date client varchar(40) as just an example, u can retrieve Reservations that fall between two dates as $initial_date = '2008-03-15'; $final_date = '2008-03-16'; SELECT * FROM reservations WHERE start_date >= $initial_date AND start_date <= $final_date which wud grab any reservations that begin within that date however we also want to check the end dates for any overlap SELECT * FROM reservations WHERE (start_date >= $initial_date AND start_date <= $final_date) OR (end_date >= $initial_date AND end_date <= $initial_date) OR (start_date >= $final_date AND end_date <= $final_date) which wud return any reservation that is within or overlaps on those dates. I believe all the logic is there
  21. Look into path_info setup of Apache and php. if pathinfo is setup u can have urls like http://www.xxx.yyy/sig.php/my.jpg
  22. if this is a reservation system, then u shud be using SQL. and u shudn need a hardcoded system like this.
  23. ya ya will encounter that. u can use explode/implode to temporarily split everything into an array using the '?' as a seperator, than do yer search/replace then recombine everything back
  24. U have to put thought into yer layouts. and use a weighted/positional system. so say in yer layuout, u have 3 positons left,center,right now, we want menu on left side very top we wud design our db to use this type of info. TABLE id integer position tinyint menuposition tinyint module varchar position, u can assign 0 = left 1 = center 2 = right according to yer layout menuposition, u assign where it goes so say u have a login_box and a navmenu as modules, and u want them both on left side with login_box always on top id position menuposition module 0 0 1 navmenu 1 0 0 login_box now when u go thru the db, remeber to SORT BY menuposition ASC so the login_box always comes first, no matter what id it has
  25. LOL, love these forums. as other users show the different functions php has. Nice job discomatt
×
×
  • 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.