WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : stock, quotes, finance, financial, level
Categories : PHP, Complete Programs Update Picture
Toast Boy
Date : Sep 21st 1999
Grade : 5 of 5 (graded 1 times)
Viewed : 5821
File : mach3.php3
Images : No Images for this code example.
Search : More code by Toast Boy
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?
/*
** All Quotes ver 1.2 mach3.php3
** Author: toastboy@mindless.com
** Date: Sept 8 1999
**
** All Quotes steals quotes from quote.com
** without there permission.
** So use this at your own risk and feel
** free to customize it to your liking
**
*/

$symbols = ereg_replace(32, ":", $s) ;
$ticker = split(":", $symbols, 2) ;
$hostname        =        "mach.quote.com";
$port                =        80;
$uri                =        "/fq/fq_quote.asp?symbols=" ;
$uri                .= (Chop($ticker[0])) ;
$uri                 .= "&symtype=" ;
$uri                .= (Chop($symtype)) ;
$uri                .= "&mode=" ;
$uri                .= (Chop($mode)) ;
$header_passed        =        0;
$cache_file        =        "/tmp/mach.cache";
system("rm -f $cache_file") ;
if($symbols != "") {
if ((!file_exists($cache_file)) ||
                 (!filesize($cache_file))) {
        $fpread = fsockopen("$hostname",
        $port, &$errno, &$errstr);
        if(!$fpread) {
                echo "$errstr ($errno)<br>\n";
        } else {
                fputs($fpread,"GET $uri HTTP/1.0\n\n");

                $fpwrite = fopen($cache_file, "w");
                while (!feof($fpread)) {
                 $page = Chop(fgets($fpread, 1500));
                                fputs($fpwrite, "$page\r\n");
                        }
                
                fclose($fpwrite);
        }
        fclose($fpread);
}
$web_content = fopen($cache_file, "r") ;

function clean(&$inputString) {
$inputString = ereg_replace("\&nbsp\;", "", $inputString) ;
$inputString = strip_tags($inputString);
}
while(!feof($web_content)) {

$line = fgets($web_content, 1500) ;
// remove all tabs
$line = ereg_replace(9, "", $line) ;

/*
** Check to see if they can validate the
** symbol first.
**
*/
if(ereg("Unable.*$", $line)){
        print "<html>\n";
        print "<head>\n\n" ;
        print "<title>Delayed Quotes for " ;
        print strtoupper($ticker[0]) ;
        print " - $company</title>\n" ;
        print "</head>\n" ;
        print "<body bgcolor=\"#ffffff\">\n" ;
        print "<table width=\"780\">\n" ;
print "<tr>\n" ;
print "<td width=\"150\">" ;
        print "<form method=post>\n" ;
print "Symbol: <input type=\"text\" name=\"s\" value=$s size=\"8\" maxlength=\"6\">\n" ;
print "</form>" ;
        print "</td>\n" ;
print "<td width=\"530\" valign=\"top\">\n";
        print "<table width=\"100%\" border=\"0\"" ;
        print " cellPadding=\"1\" cellSpacing=\"0\">\n" ;
        print "        <tr>\n" ;
        print "<td colspan=5 bgcolor=\"#eeeeee\">" ;
        print "<p><font face=\"Arial,Helvetica,Sans-Serif\"";
        print " size=\"2\"><center>\n" ;
        print $line ;
        print "</font></center></p>\n";
        print "</td></tr>" ;
        print "</table>\n" ;
        print "</table>\n" ;
        print "</body>\n</html>" ;
        exit ;
                                        }

/*
** Because the +/- comes in a gif
** find the gif and replace with
** proper symbol +/-
*/
// down_arrow now is minus
         if(ereg(".*down_arrow.*$", $line))
                 {
                         $line = ereg_replace("^\<img
src\=\"images/down\_arrow\.gif\" WIDTH\=10 HEIGHT\=8\>", "-", $line) ;
                         $change = $line ;
                         $font_color = "#ff0000" ;
                        }
                        
        // up_arrow now is plus                        
        elseif(ereg(".*up_arrow.*$", $line))
                 {
                         $line = ereg_replace("^\<img src\=\"images/up\_arrow\.gif\"
WIDTH\=10 HEIGHT\=8\>", "+", $line) ;
                         $change = $line ;
                         $font_color = "#000000" ;
                        }
        
// get company name or ticker
// if on the Bulletin Board

if(ereg("^<b>\&nbsp\;.*<\/b><\/font><\/td>.*$", $line)){
clean($line) ;
if(ereg(".*\:.*", $line)) # then must be a BB stock
{
$market = split("[\:]", $line,5);
$company = $market[1] ;
         } else {
$company = $line;
}
}

// get the trading time
if(ereg("^<b>.*\&nbsp\;<\/b><\/font><\/td>.*$", $line)) #then we have a date
{
         $trade_time = trim($line) ;
         $trade_time = ereg_replace("<b>", "", $trade_time);
         $trade_time = ereg_replace("\&nbsp\;<\/b><\/font><\/td>", "", $trade_time);
         $trade_time = trim($trade_time) ;
         }

// get numbers to play with

if(ereg(".*<\/font>\&nbsp\;<\/td>.*$", $line))
{
$line = ereg_replace("<\/FONT>", "", $line) ;
$line = ereg_replace("<\/font>\&nbsp\;<\/td>", ":", $line) ;
$line = ereg_replace("\&nbsp\;", "", $line) ;
$line = ereg_replace(10, "", $line) ;
$bers = ereg_replace(13, "", $line) ;
$new .= $bers ;
}
}
$sentence = split("[\:]", $new, 18) ;
$last_sale = $sentence[0];
$open = $sentence[1];
$change = $sentence[2];
$prev_close = $sentence[3];
$percent_change = $sentence[4];
$week_high = $sentence[5];
$volume = $sentence[6];
$week_low = $sentence[7];
$high = $sentence[8];
$EPS = $sentence[9];
$low = $sentence[10];
$ratio = $sentence[11];
$bid = $sentence[12];
$div_per_share = $sentence[13];
$ask = $sentence[14];
$exchange = $sentence[15];
$last_trade_size = $sentence[16];
$ind = split("\:", $sentence[17],2) ;
$industry = $ind[0] ;
$company = trim($company) ;
/*
** Generate HTML page with output
** values.
*/
print "<html>\n";
        print "<head>\n\n" ;
        print "<title>Delayed Quotes for " ;
        print strtoupper($ticker[0]) ;
        print " - $company</title>\n" ;
        print "</head>\n" ;
        print "<body bgcolor=\"#ffffff\">\n" ;
        // start of left hand side
        print "<table width=\"780\">\n" ;
print "<tr>\n" ;
print "<td width=\"150\" valign=\"top\">" ;
        print "<form method=post>\n" ;
print "Symbol: <input type=\"text\" name=\"s\" value=\"$s\" size=\"8\" maxlength=\"6
\">\n" ;
print "</form>" ;
        print "</td>\n" ;
        // end left side
print "<td width=\"530\" valign=\"top\">\n" ;
        print "<table width=\"100%\" border=\"0\"" ;
        print " cellPadding=\"1\" cellSpacing=\"0\">\n" ;
        print "        <tr>\n" ;
        print "<td colspan=3 bgcolor=\"#ffffff\">" ;
        print "<font color=\"#413d92\" face=\"Arial,Geneva,Helvetica\"" ;
        print " size=\"2\">" ;
        print "<b>$company</b></font></td>\n" ;
        print "<td colspan=2 bgcolor=\"#ffffff\" align=right>";
        print "<font color=\"#413d92\" face=\"Arial,Geneva,Helvetica\"" ;
        print "size=\"2\">" ;
        print "<b>$trade_time</b></font></td>\n" ;
        print "</tr>\n" ;
print "<tr bgcolor=\"#eeeeee\">\n" ;
        print "<td width=20%><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">&nbsp;Last Sale</font></td>\n" ;
        print        "<td width=22% align=right><font FACE=\"Arial,Geneva,Helvetica\"";
        print " SIZE=\"2\">$last_sale</FONT></font>&nbsp;</td>\n" ;
        print        "<td width=7%>&nbsp;</td>\n" ;
        print "<td width=20%><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">Open</font></td>\n" ;
        print "<td width=31% align=right><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$open</FONT></font>&nbsp;</td>\n" ;
        print "</tr>\n" ;
print "<tr bgcolor=\"#cccccc\">\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"";
        print " SIZE=\"2\">&nbsp;Change</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"";
        print " SIZE=\"2\" color=$font_color>$change</font>&nbsp;</td>\n" ;
        print "<td>&nbsp;</td>\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"";
        print " SIZE=\"2\">Previous Close</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"";
        print " SIZE=\"2\">$prev_close</FONT></font>&nbsp;</td>\n" ;
        print "</tr>\n" ;
        print "<tr bgcolor=\"#eeeeee\">\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">&nbsp;% Change</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$percent_change</font>&nbsp;</td>\n" ;
        print "<td>&nbsp;</td>\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">52 Week High</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$week_high</FONT></font>&nbsp;</td>\n" ;
        print "</tr>\n" ;
        print "<tr bgcolor=\"#cccccc\">\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">&nbsp;Volume</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$volume</font>&nbsp;</td>\n" ;
        print "<td>&nbsp;</td>\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">52 Week Low</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$week_low</FONT></font>&nbsp;</td>\n" ;
        print "</tr>\n" ;
        print "<tr bgcolor=\"#eeeeee\">\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">&nbsp;Today's High</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$high</FONT></font>&nbsp;</td>\n" ;
        print "<td>&nbsp;</td>\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">EPS</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$EPS</font>&nbsp;</td>\n" ;
        print        "</tr>\n" ;
        print "<tr bgcolor=\"#cccccc\">\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">&nbsp;Today's Low</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$low</FONT></font>&nbsp;</td>\n" ;
        print "<td>&nbsp;</td>\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">P/E Ratio</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$ratio</font>&nbsp;</td>\n" ;
        print "</tr>\n" ;
        print "<tr bgcolor=\"#eeeeee\">\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">&nbsp;Bid</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$bid</FONT></font>&nbsp;</td>\n" ;
        print "<td>&nbsp;</td>\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">Dividend Per Share</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$div_per_share</font>&nbsp;</td>\n" ;
        print "</tr>\n" ;
        print "<tr bgcolor=\"#cccccc\">\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">&nbsp;Ask</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$ask</FONT></font>&nbsp;</td>\n" ;
        print "<td>&nbsp;</td>\n" ;
        print "<td><font face=\"Arial,Geneva,Helvetica\"" ;
        print " size=\"2\">Exchange</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$exchange</font>&nbsp;</td>\n" ;
        print "</tr>\n" ;
        print "<tr bgcolor=\"#eeeeee\">\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">&nbsp;Last Trade Size</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$last_trade_size</font>&nbsp;</td>\n" ;
        print "<td>&nbsp;</td>\n" ;
        print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">Industry</font></td>\n" ;
        print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
        print " SIZE=\"2\">$industry</font>&nbsp;</td>\n" ;
        print "</tr>\n" ;
        print "</table>\n" ;
        print "</body>\n</html>\n" ;
        
}else {
print "<html>\n";
        print "<head>\n\n" ;
        print "<title>Delayed Quotes for " ;
        print strtoupper($ticker[0]) ;
        print " - $company</title>\n" ;
        print "</head>\n" ;
        print "<body bgcolor=\"#ffffff\">\n" ;
        // start of left hand side
        print "<table width=\"780\">\n" ;
print "<tr>\n" ;
print "<td width=\"150\">" ;
        print "<form method=post>\n" ;
print "Symbol: <input type=\"text\" name=\"s\" value=\"$s\" size=\"8\" maxlength=\"6
\">\n" ;
print "</form>" ;
        print "</td>\n" ;
        // end left side
        // start right side
print "<td width=\"530\" valign=\"top\">\n";
        print "<table width=\"100%\" border=\"0\"" ;
        print " cellPadding=\"1\" cellSpacing=\"0\">\n" ;
        print "        <tr>\n" ;
        print "<td colspan=5 bgcolor=\"#eeeeee\">" ;
        print "<p><font face=\"Arial,Helvetica,Sans-Serif\"";
        print " size=\"2\"><center>\n" ;
        print "Please enter a stock symbol.<br>\n" ;
        print "</font></center></p></td>\n" ;        
        print "</tr>" ;
        print "</table>\n" ;
        print "</body>\n</html>" ;
        }
?>



phpYellow Pages Standard
Categories : PHP, Complete Programs, Databases, Directories, Search
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
phpAds, a complete banner and ad management system with detailled tracking and stats.
Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases
Point and Click Interface ala MS Access for creating SQL statements.
Categories : MySQL, Complete Programs, General SQL, PHP, Databases
Client classes for Dictionary servers UPDATED: 2000-06-06
Categories : Network, Search, Complete Programs, PHP Classes, PHP
Example voting script. Lets people enter suggestions and vote for existing ones.
Categories : MySQL, PHP, Cookies, Complete Programs, Databases
Functions to access a NNTP/NNRP newsserver. Complete set with examples is at ftp://ftp.nederland.net/pub/nnrplib
Categories : Search, PHP, Complete Programs
php Free chat simple fast and customizable chat server that uses a simple filesystem for message and nickname storage
Categories : PHP, AJAX, XML, Complete Programs
A set of functions sitting on top of the abstraction layer that makes it a little easier to do SQL stuff. Documentation is within
Categories : Databases, ODBC, Complete Programs, PHP
simple shopping cart for php3
Categories : PHP, PHP Classes, Complete Programs, Ecommerce
A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed.
Categories : Date Time, PHP, Complete Programs, Calendar
A simple bubblesort that takes 2 arrays as argument.The first one is the actual data used for sorting, the second is data that will "tag along" with the first array, for instance a descriptive text about the data in the first array.
Categories : Algorithms, Arrays, PHP, Complete Programs
PHP-MySQL shopping cart
Categories : PHP, Ecommerce, Complete Programs
Searches through a local INN server's discussions
Categories : Search, Complete Programs, PHP
An email validation script that actually checks against the recipient's mail server.
Categories : Email, Complete Programs, PHP, Network, Debugging
 Andrew Bonar wrote : 143
I downloaded and uploaded it 
http://www.necromancer.co.uk/test.asp . It does not 
seem to bring any info back.....
 
 Toast Boy wrote :261
To get a working copy of the script just visit toastboy.com

Click on the Stock Quote Link.

I have had to rewrite the script as quote.com changes their data format often.  I have a working version
using Yahoo! feed.