-
Posts
171 -
Joined
-
Last visited
Never
Everything posted by bibby
-
Are you managing the file using the superglobal $_FILES , or is the script of another flavor? You could save the user some time by recalling $_FILES['[i]fieldname[/i]']['name']
-
Did this happen before you started echo'ing it out? Try putting that assignment in parenths. echo ($person=$_REQUEST['blah']); This way it truly gets assigned before printing. Just a guess.
-
Will that work in Safari? I usually don't style form elements because of that. What I see with Ubuntu/Firefox, it looks pretty cool
-
[url=http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html]http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html[/url]
-
kind of agreeing with anatak here, it sounds sketchy. Can we ask, does the site know you're doing this?
-
how's your php , faizulbari ? You'll definately want to do two things, separate your different registrations from each other and then separate the data for each registration. When confronted with a outside form, you can still submit to the post handler after writing your own form. :load up the file: Read and adapt the user scripts from these pages. [code]<? $file='/path/to/yourfile.csv'; if(file_exists($file)) $records=file($file); else echo "I can't find $file"; ?>[/code] :separating records: Hopefully, each new record is on it's own line. file() as already split them into an array. [code] if(is_array($f)) foreach ($f as $index=>$text) { $x=explode(',',$text); foreach($x as $k=>$temp) $x[$k]=trim($temp); $parts[]=$x; } [/code] Now you have an array of arrays. print_r($parts) to see it. I imagine it's something like [code]parts= Array( 0 = Array( 0=>'blah' 1=>'blah' 2=>'blah' ) 1 = Array( 0=>'blah' 1=>'blah' 2=>'blah' ) )[/code] I'll leave the rest up to your imagination, but what you could do with this giant array now is use it to create 100 new forms that just need their submit buttons touched. Or, and I like this one, make a page that has 100 forms (hidden text of course) and 100 submit buttons. In 100 clicks, yer done.
-
I'm trying to blow your mind or nothin, but you can do your flags in a single field, if you felt like it, using bits. [url=http://us3.php.net/manual/en/language.operators.bitwise.php]http://us3.php.net/manual/en/language.operators.bitwise.php[/url] [url=http://en.wikipedia.org/wiki/Bitwise_operation]http://en.wikipedia.org/wiki/Bitwise_operation[/url] Say you have 4 flags (quests in a game). ! - Defeated Ogre ! - Saved the old man ! - Helped Timmy out of the well ! - Slayed the Dragon Any could be on or off at any given time. Assign them binary values relating to decimal place. 1 - Defeated Ogre 2 - Saved the old man 4 - Helped Timmy out of the well 8 - Slayed the Dragon If I saved the old man and helped timmy, my number is 6. Some bitwise operators are '&' , '|' (ever wonder why you've been using && and || ? These are tests for truth, return 1 or 0) [code] if (($myNumber & 2) == 2) echo "you had saved the old man"; /* $mynumber=6; 6 in binary is 110 . 2 in binary is 10. So 0110 & (& finds like bits) 0010 = ----- 0010 */ [/code] To try to answer your question though, you could use a function. Write it once, use it wether you have 31 fields or 31,000 fields. [code] function countFlags($flagnum) { $q=mysql_query("select sum($flagnum) from flags"); $r=mysql_fetch_row($q); return $r[0]; } function countAllFlags() { for($i=1;$<=31;$i++) $list.=$i . ' - ' . countFlag($i) return $list; } echo countAllFlags(); [/code]
-
[url=http://www.jedit.org]http://www.jedit.org[/url] Jedit is by far my favorite text editor for a number of reasons (all platform being number 1), but the "dry install" doesn't have everything that you'd want. This is easily remedied, so here's a short To-Do to get you rolling with Jedit. Firstly, it doesn't have FTP/SFTP out of the box, you'll have to get it as a plugin. But the default site that it tries to get plugins from is unresponsive most of the time, so select a different mirror: From the top menu, select Plugins -> Plugin Manager -> Download Options -> Update mirror list -> (pick something other than Central default, like UofM). Now you can get your plugins. FTP you'll want for sure. BufferTabs is great if you don't like the dropdown for open files. PHPParser is great if for your PHP scripts (includes dockable panes for error checking and class/function structure). I suggest getting to know how what your docking options now (Utilities->Global Options->Docking). I keep my Structure browser and ErrorList docked left, and my BufferTabs docked at the top, but that's just me. Take a few minutes to play with the colors too. I love having a black background. (Global Options -> TextArea , SyntaxHighlighting) mmmm, Jedit. ;D
-
Wouldn't you rather interpolate the weekday based on the other 3 params? What is I select Monday Januray 1 2007 and Tuesday Januray 1 2007 ??
-
heh, I didn't even know about decimal. I guess I gave away that my projects aren't carts. Thanks guys.
-
Leon, I've been back and forth on this topic ever since php 4 was released, and I'm still more on the side of class-less "procedural code". The biggest arguments that I've absorbed for using classes is portability. A "good" class should not try to do too much, it does what is does and and that's it, making it so that you can begin a brand new project and still be able to use that class and not worry about it failing. Classes can also share functions. Say I have a database object and product object, and there's a method of product that I want to apply to my database widget. I shouldn't add a special function to the database class because I'm using that for every project that I own, but I don't have to. I don't even have to think about it though, I can use a product function whenever.. [code]$DBObject->Product::neatFunction(); // one object using another's function.[/code] ---------- Another idea. You begin to wish you were using objects as soon as your functions begin to take four or more parameters. A lot of your most complicated functions could take one, the object, and work itself out from within. The object in that instance is just a big array. ------------ Final thought. In some languages (from what I understand C++,Java, don't really know), classes and objects are a must in order to do anything. Adding Object oriented syntax to PHP is, in my opinion, most beneficial to those that are already used to being in that state of mind. It is argued as well, and I agree, that PHP's objects aren't really objects anyhow, as PHP is an interpretive language, so it's all kind of a rouse. I'm only posting here to begin the discussion. I'm really asking the forum the same question, Leon. I'm not completely sold on PHP objects, and continue to write procedural code more often than not.
-
Linux isn't an OS, btw. It's a kernel. Ubuntu, Fedora, and RedHat are OSs.
-
everything you ever wanted to know about the net is somewhere on the net
-
jesirose, look at border-spacing and border-collapse . [url=http://www.w3.org/TR/REC-CSS2/tables.html#separated-borders]http://www.w3.org/TR/REC-CSS2/tables.html#separated-borders[/url]
-
yeah, don't put your function call in window.open, (!) window.open('[b]constructCalendar()[/b]') call a different function that does both. onclick="launch()" function launch should then call window open. What does construct calendar do? Is it something that the destination page should handle instead? Because once that window's open, there's only so much you can do with it from here.
-
great link obsidian. thx!
-
[code] //lol, great name for this fxn. function valiDate(input) { if(document.getElementById(input)) { //gave it an id ? var ymd=input.value.split('-'); if (ymd[0].length=='4' && !isNan(ymd[0])) { // is a number by !isNan? (not (is not a number)?) var yeargood=true; } else { var yeargood=false; } // ect. same for month, same for day. // return in the end, true or false, handle as you see fit. } // else there is no id for that input } [/code]
-
amendment.... you're going to need to pass around the full path too. $_SERVER['DOCUMENT_ROOT'] to start out with, and then you'll have to append each level. [code] function readDirectory($dir , $subpath=FALSE); [/code]
-
[quote]I don't want to create each level by hand, because you never know how many levels deep the subdirectories[/quote] Right, so you right a function for it that can recursive onto itself [code] function readDirectory($dir) { //blah blah, read files while ($file) { if(is_dir($file)) readDirectory($file); <---- recurse!! } else { # whatever you do with files } } [/code] Call the function once on your target directory, and it should handle any depth.
-
[SOLVED] Using if (isset($_POST['ap_nmF'])) on radio buttons
bibby replied to DBookatay's topic in PHP Coding Help
meh -
cturner, you defiantely need to learn how to use functions for repetitive tasks. If I find myself doing ANYTHING twice, it becomes a function. [url=http://us2.php.net/manual/en/language.functions.php]http://us2.php.net/manual/en/language.functions.php[/url] That aside, you have some error handling (visually checking the post), but you don't have the good stuff. If your query doesn't run, echo mysql_error(); echo'ing out $update could help as well. I bet that the hint you want is in mysql_error();
-
I'm going with no on this one. If you want to see everything that is known though, [code]print_r($_FILES);[/code]
-
[SOLVED] Using if (isset($_POST['ap_nmF'])) on radio buttons
bibby replied to DBookatay's topic in PHP Coding Help
Do you ppl code? He's trying to get the value of his radio choice into a text field. Bookatay, what you have should work if POST['ap_nmF'] is set. Is It ? create an ELSE and see what happens.. -
[SOLVED] php/mysql date manipulation (for annual membership periods)
bibby replied to brett24's topic in PHP Coding Help
time() is an ok solution if you are always going a year from now, but memberships are most often renewed before they expire. So if my expiration date is 2007-06-01 (date format, not unix time), and I wanted a add a year from THEN, try [code] update members set expDate = concat( date_format(expDate,'%Y')+1 ,date_format(expDate,'-%m-%d') ) where mbrID=1; [/code] That gets you year beyond what I'm already due. Be careful that if the membership is expired already not to shirtchange them, (use now) [code] concat( date_format(now(),'%Y')+1 ,date_format(now(),'-%m-%d')) #year from now without php [/code] How you handle leap years is up to you. What you consider correct is correct. This method grants the occasional 366 day-year. -
My friend is using picture trivia, using random photos found on the net. There are a series of questions possible questions associated with each photo, so the photo can be reused. This of course is not a very good use of his time (creating questions and answers), when it should be random. For example, a photo of hot babes at a bar. Questions would be, "What color is the redhead's shirt?", "How many bottles are on the bar?". What's the problem with captchas anyhow?