November, 2009 Maxims Date : 11-19 20:12: Views: 1805 Comments : 0 Topic :Aphorisms Aphorisms Date : 11-17 13:25: Views: 1017 Comments : 0 Topic :Aphorisms Review of The Lexicographer's Dilemma Date : 11-03 19:51: Views: 5317 Comments : 0 Topic :Books gpullman@gsu.edu | Published: 08-25 2007 Title: Auto Columns Topic: PHP <? $query = mysql_query($sql4) $num_rows = mysql_num_rows($query4); echo "<tr><td colspan=4><B>name</B>: </td></tr>"; if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) { echo "</table>"; Published: 04-13 2007 Title: Image Randomization Topic: PHP (link) <?php
//By Angela Bradley for PHP @ About.com
//Assign the image and link URLs here, you can add more following this formatt
$Img1 = "http://goat.ws/board/images/avatars/114693804644304f35a8399.jpg";
$Url1 = "http://www.goat.ws";
$Img2 = "http://goat.ws/board/images/smiles/gamesc.gif";
$Url2 = "http://www.identity.st";
$Img3 = "http://goat.ws/board/images/avatars/11415438874159139eaacbe.gif";
$Url3 = "http://php.about.com";
//Leave the first number as 1, and set the second to how many banners you have
$num = rand (1,3);
//This creates the variables
$Image = ${'Img'.$num};
$URL = ${'Url'.$num};
//This actully outputs the banner
Print "<a href=".$URL."><img src=".$Image." border=0></a>";
?>Published: 04-11 2007 Title: Switch snippet Topic: PHP <?php switch($id) <ul> Published: 11-15 2005 Title: Deadline enforcer Topic: PHP One of the advantages to having writing assignments done online is that you can more easily enforce deadlines. The basic idea is compare the current time to a deadline and branch when deadline = now. The easiest way is to do something like: $now = date(Y - f - d); if ($deadline - $now < 0){ The problems with this approach are numerous, but include the fact that hours are not part of the equation. Here is a better way, <? function second2min($arg){ } print "It is now :<BR>"; $d = dateTimeDifference($due,$today); if($d <="0"){
print "<h3>Instructions</h3> ";
Published: 10-02 2005 Title: Cron job Topic: PHP Good article at Sitepoint about using cron job and php. (link) Published: 09-22 2005 Title: Pulling content from a db Topic: PHP $query = "SELECT * FROM TABLE"; } OR while(list($name,$etc)=mysql_fetch_row($result)){
Published: 09-21 2005 Title: Scheduling software Topic: PHP I've looked unsuccessfully for some time now for a php script that would enable my colleagues and I to find mutual meeting times. Finally I've written my own. If there is an ugliest code competition, it could win. But it does work. You will need a php and mysql enabled webserver. The two files, the php and the sql db setup file are zipped here. It occurs to me that this software might be more useful if it had a javascript calendar that would allow the organizer to sellect the week, since any given week is bound to have anomolies. Published: 09-21 2005 Title: Redirect Topic: PHP print "<meta http-equiv='refresh' content='1; url=http:file.php' />"; Published: 09-19 2005 Title: loop through an array Topic: PHP <?php foreach($arrayname as $key=>$value) { echo $key.": ".$value; } ?> Published: 05-03 2005 Title: CSS skinner Topic: PHP 0 <? (link) Published: 05-22 2004 Title: php graphics Topic: PHP I need to learn how to represent data graphically so that i can report the findings of the 1101-T tech survey to APACE. I've found a useful chapter in the PHP5MYSQL Bible, and the basic idea is represented at bar_graph_form.php Published: 05-18 2004 Title: print a list of a db's field names Topic: PHP $fields = mysql_num_fields($result); for ($i=0; $i < $fields; $i++) { print "$name<br>"; Published: 05-08 2004 Title: Print all variables Topic: PHP This snippet will print all of the variables as name value pairs. Handy for showing the user what they entered. // Print POST Variables If you replace the previous print statement with this: print "$". $key .","; you get a string of comma seperated variables like this: $name,$phone,$email, You could then assign that string to a variable for a msql statment. Well, no actually, you can't. the problem that i can't solve is that the msqyl value statement can't end with a comma and every way i tried to remove it failed. So I'm still looking. Published: 05-08 2004 Title: Multiple form select Topic: PHP (link)
multiple_select.htm Published: 04-24 2004 Title: cache prevention Topic: PHP <?php header("Cache-Control": no-cache, must revalidate"); header("Pragma: no cache"); header("Expires: Mon,26 Jul 1997 05:00:00 GMT"); ?> Published: 04-15 2004 Title: PHP forms automator Topic: PHP I found this code at Zend. It automates the process of creating a form by transforming a string of names into textboxes with names and values set to whatever you put in the string. So all you have to do is come up with your lables for the form and it makes the form. I was thinking about making something like this to make webforms to mysql dbs more efficiently. It won't do the mysql part, but it could be hacked to, i think. <?php // copyright © 2000-2002 ilija injac injac@article-24.com
Published: 04-13 2004 Title: msword cleaner? Topic: PHP In the process of building online writing tools i've repeatedly come up against problems created by ms-code when people cut from a word file and paste into a form. There are methods for dealing with this. I found one at chuggnutt.com. I put an example in the fyc directory under clean.php. I'm not sure it does what I want because it seems to remove too much formatting but I need to work with it further. Published: 04-13 2004 Title: user logs Topic: PHP There's a nice tutorial over at phpfreaks about building a log script. <?php Published: 04-03 2004 Title: Excellent php help Topic: PHP I don't know why i didn't notice this before, or if i did why i didn't register it, but w3schools, which is excellent for css is also pretty handy for php. Published: 04-03 2004 Title: form checking Topic: PHP I think the following code could be use to check if fields have been left blank. if ($name == "" || $email == "" || $password == "") { Haven't checked it yet, though. Published: 01-20 2004 Title: Automate mysql Insert directives Topic: PHP A script called Echelon SQL perports to create the values $ pairs on the fly so that to put form contents into a db, all you hae to do is create the form with name="name" and the tables with the same names and connect the form to the db. Echelon stuffs the content. I haven't used it yet as i can't untar from the machine I'm on, but I'm eager to try it out. http://www.digitalthought.net/sections.php?op=viewarticlesp&artid=3
Published: 01-13 2004 Title: php tutorials Topic: PHP An excellent collection of turorials on various methods related to forms, files, counters, etc. (link) Published: 01-11 2004 Title: Date transformation Topic: PHP Problem: date is in 2004-01-31 format and you want it printed as January 31 2004. Solution: $test = explode("-",$date); // Generate the month text for the numbers (returns a string) //applies the above function to the month created by explode above $m = genMonth_Text($m); echo "$m $d $y"; Published: 12-21 2003 Title: heredoc command Topic: PHP when writing php enabled webpages, it's tedious to have to write the html inside print statements and to remember to escape everything prperly. An alternative is to use the heredoc command. Everything between <<<EOD and EOD is leteral, plain html. <?PHP
Published: 12-16 2003 Title: deadline imposer Topic: PHP Below is a script that reads a date from a file and compares it to today's date and then decides what to display based on whether today's date is greater than or equal to it. <? $cuttoff = "deadline.txt";
$today = (Date('F d, Y')); if($today <= $cuttoff){ echo "I'm sorry. The deadline for this semester has passed. Please comeback next semester."; } ?> Published: 11-21 2003 Title: Forms -- action = self Topic: PHP To reduce the number of php files, execute a form's action statement from within the form itself. <? if ($submit) { // process form } ?>
Remember to name the submit button submit. And use $_GET['value']; instead of $_POST Published: 11-16 2003 Title: Averaging Data Topic: PHP This should be cross listed with mysql. After gathering data from a form and putting the responces into a db, I used this script to extract the numbers from a field, average them and then print them rounded to two decimal places. It's a bit clumsy because the number of entries is hard coded (45). it would be better if the script first added the number of entries on the ID field and then used that number as the divisor for the average.
$query="SELECT sum(FIELD) FROM study"; $num = mysql_result($result,0,0); $div = "45"; $average = $num / $div; print round($average, 2); Published: 11-15 2003 Title: Printing data Topic: PHP I used this script to pull info from a db and print it to the screen. The $field<0 keeps it from printing empty entries.
<? // Printing results in HTML while ($get_info = mysql_fetch_row($result)){ print "$field<br><br>"; ?> Published: 11-02 2003 Title: Group email from db Topic: PHP connect to db // create SQL statement $result = mysql_query($sql,$connection)
$update = "Hello Curriculum Committee Members:\n\n"; mail("$email", "A&S Curriculum Committee",$update, "From: gpullman@gsu.edu"); Published: 10-28 2003 Title: Writing form to file Topic: PHP
// The next line opens a file handle to a file called form.htm // for it to work you have to have a file called file.htm in the same directory with permissions set to 755
if (!$out) { // fputs writes output to a file. the syntax is where to write
fclose($out); ?> Published: 10-02 2003 Title: getting all variables from a form at once Topic: PHP @extract($_POST); apparently reads all of the name=value pairs into an array. (link) Published: 09-24 2003 Title: Code for printing file backward Topic: PHP I used this to print a most recently updated blogs file to the screen: <? $lines = file('updates');
The content of "updates" is provided by a simple form to file script that prints a line of text for each entry, including link to the blog. It's not very sophisticated but it does work. The script above reads a file into an array (file has to have entry per line) and then reverse sorts the array by key rather than value.
Published: 08-26 2003 Title: Turorial Site Topic: PHP A site with helpful tutorials, including a regular expression snippet collection that can be used to validate phone numbers, email addresses, etc. (lnik) Published: 08-18 2003 Title: Date formatting Topic: PHP A typical application of the date command in php would be <?php print date("Y:m:d H:i") ?>. The colons are purely visual elements. Here is a table naming and describing the php date codes. (link)
Published: 06-04 2003 Title: Calendar navigation code Topic: PHP I've been looking some time now for a good explanation of a calendar navigation scheme, liek those used in blogs. Devarticles.com has a calendar tutorial that's very easy to follow. It writes to a text file innstead of a db. That wold be perhaphs easy to change but it might also be preferable to leave it the way it is. (link to my example) Input
AdminAdd Email updates Links
Aldaily Blogrunner Books24/7 Digg Gizmodo Google News Inform Internet news LifeHacker News Now UK News Wire Overheard NYC rhetcomp Sifry's Alerts Web Dev Hndbk Webcreme Topics 8123 (47)adult literacy (20) Aphorisms (8) Blogging (81) Blogging & Teaching (3) Blogging History (0) Blogging Software (16) Books (34) CMS (5) commonplaces (22) Composition (9) critical thinking (3) CSS (33) CTW (3) DTP (2) E-texts (1) Epolitics (2) Home Repair (1) InfoVis (2) Java (0) Javascript (3) misc (29) MySQL (1) news (1) Open source (3) PHP (35) PR (2) QEP (3) rhetoric (39) Robotic grading (6) RSS (6) Social Software (2) Software (9) Teaching (15) Usability (2) Writing (41) | |||||||||||||||||||||||||||||||||||||||||||||||||||||