Skip to content

notes to self

a document of a plodding mind

Menu
Menu

PHP: Locator script

Posted on July 30, 2009July 30, 2009 by abram

When asked to write a store location program in less than an hour, I developed this little utility. It uses my own MySQL class and clean() function which parses the POST/GET variables for any nastiness that might have occurred.

include('includes/class.mysql.php');
include('includes/functions.php');

clean(); // Clean up $_REQUEST for SQL injection
$mysql = new mysql();
$zip = $_REQUEST[zip];
$city = $_REQUEST[city];
$digits = strlen($zip);
//echo "Count: $digits
"; echo "\n\n"; echo "\n"; while($i<1) { $q = ($zip) ? $mysql->query("SELECT * FROM stores WHERE zip LIKE '$zip%'") : $mysql->query("SELECT * FROM stores WHERE state = '$_REQUEST[state]' AND city LIKE '%$city%' ORDER BY zip ASC"); if(mysql_num_rows($q)) { while($r = mysql_fetch_assoc($q)) { echo "\t\n"; echo "\t\t".trim($r[chain])."\n"; echo "\t\t".trim($r[store])."\n"; echo "\t\t".trim($r[location])."\n"; echo "\t\t".trim($r[city])."\n"; echo "\t\t".trim($r[state])."\n"; echo "\t\t".trim($r[zip])."\n"; echo "\t\n"; } $i++; } else if (strlen($zip) > 1) { $zip = substr($zip, 0, strlen($zip) - 1); } else { $i = 1; } } echo "\n"; echo "\n";

Leave a Reply Cancel reply

You must be logged in to post a comment.

about

Abram Morphew is an electrical engineer, bedroom musician, composer, naturalist, and amateur scientist. I play music in the the binary marketing show. This blog is a catalog of stuff that I make or bits of information that I think could prove useful later on when memory fails me.

 

I currently hold an Extra Class Amateur Radio Operator license and transmit on the air as K2NXF.

Tags

40m amp amplifier Arduino atmega328 atmel audio bash bjt breadboard circuit code cw delay digital effect effects electrical electronics homebrew lfo linux LM386 mellotronium music no. 5 opamp oscillator pcb pedal photos php pt2399 pwm radio rf schematic stereo stompbox synth tape TDA2040 tl072 TL082 tube

Social

  • Instagram
  • LinkedIn

Space Weather


© 2026 notes to self | Powered by Minimalist Blog WordPress Theme