PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
upennballer
New Member
New Member


Joined: Jun 10, 2004
Posts: 16

PostPosted: Thu Jun 10, 2004 11:06 am Reply with quote Back to top

Hi. Great work. I am trying to install this into a regular html document. I have php installed. How would i go about including this? Is there a way to make a stock ticker? Also a bug. When showing what an index does for the day or a stock for that matter it shows the price change from the open. It should show price change from previous close.

Thanks
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 15057
Location: Kansas

PostPosted: Thu Jun 10, 2004 2:50 pm Reply with quote Back to top

This is a PHP application. If you are trying to incorporate a php application into an html document, you will have to build your html document around the php code. Or, you can try to use an INCLUDE('KISSQ/INDEX.PHP'); type approach. For example, let's say that you have an html document (hellowWorld.html) that says 'Hello World'. You might code it
Code:
<html>
  <head><title>Hello World</title></head>
  <body>Hello World</body>
</html>

Now, suppose you wanted to show the Stock Quote (KISSQ) aplication in the Body also. You might code this
Code:
<html>
  <head><title>Hello World</title></head>
  <body>Hello World<br /><br >
  <? include('kissq/index.php'); ?></body>
</html>

Now, I have not tested this, but it is the general way. This assumes that your server has been instructed to parse all *.html documents through the PHP engine. If this is not the case, you will know right away because the "include" code will appear on your screen as text. In that case you either modify your server config or you rename your Hello World script to be helloWorld.php.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
upennballer
New Member
New Member


Joined: Jun 10, 2004
Posts: 16

PostPosted: Thu Jun 10, 2004 3:35 pm Reply with quote Back to top

Thanks. I will try that. Right now i am trying to break it down so that i can pass a bunch of symbols into a ticker sort of thing. I am not sure how to start. I am using your yahoo finance links if that is okay and just trying to break it down, but i am kind of lost LOL. Go figure. I want to be able to loop it for a list of stocks. Is there a way to pass in a list of stocks. You have to pass it into an array correct? Then loop through the array getting the necessary information and storing it in variables right? Hope i am on hte right track. My Ultimate goal is to make a sweet ticker and also to have a nice symbol lookup so i might have to try out that include stuff above. I think i am going to give up on giving each person their own portfolio so i am trying to edit out all the login stuff if that is okay. Feedback is greatly appreciated THANKS!
View user's profile Send private message
upennballer
New Member
New Member


Joined: Jun 10, 2004
Posts: 16

PostPosted: Thu Jun 10, 2004 4:36 pm Reply with quote Back to top

<?php
$Symbol=qqq;
$readf = @file("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=snl1d1t1c1p2va2bapomwerr1dyj1");
if (count($readf)<1) {
echo "This symbol was not found. Please check the symbol name and try again.";
exit;
}
$readl = @file("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3");
for ($i=0;$i<count($readf);$i++) {
$read = str_replace("\"", "", $readf[$i]);
$read = explode(",", $read);
$Symbolpf=$read[0];
$Company=$read[1];
$LastPrice=$read[2];
$TradedDate=$read[3];
$TradedTime=$read[4];
$Change=$read[5];
$ChangePercent=$read[6];
$Volume=$read[7];
$AverageVolume=$read[8];
$Bid=$read[9];
$Ask=$read[10];
$YesterdayClose=$read[11];
$Open=$read[12];
$Day = split("-",$read[13], 2);
$DayHigh = $Day[1];
$DayLow = $Day[0];
$Year = split("-",$read[14], 2);
$YearHigh = $Year[1];
$YearLow = $Year[0];
$EarnPerShare=$read[15];
$PE=$read[16];
$DivDate=$read[17];
$Yield=$read[19];
$DivShare=$read[18];
$MarketCap=$read[20];

$read = str_replace("\"", "", $readl[$i]);
$read = explode(",", $read);
$TradedTime=$read[1]>$holdTradedTime?$read[1]:$holdTradedTime;
$holdTradedTime=$TradedTime;
$LastPrice=$read[2];
$Change=$read[3];
$ChangePercent=$read[4];
$Bid=$read[5];
$Ask=$read[6];
$DayHigh = $DayHigh>$LastPrice?$DayHigh:$LastPrice;
$DayHigh = $DayHigh>$Open?$DayHigh:$Open;
$DayLow = $DayLow<$LastPrice?$DayLow:$LastPrice;
$DayLow = $DayLow<$Open?$DayLow:$Open;
$YearHigh = $YearHigh>$LastPrice?$YearHigh:$LastPrice;
if (is_numeric($Open)) $YearHigh = $YearHigh>$Open?$YearHigh:$Open;
if ($changePriceMethod==1) $Change = $LastPrice>0?$LastPrice-$Open:0;
else $Change = $LastPrice>0?$LastPrice-$YesterdayClose:0;
$YearLow = $YearLow<$LastPrice?$YearLow:$LastPrice;
if (is_numeric($Open)) $YearLow = $YearLow<$Open?$YearLow:$Open;
$Change = round($Change*100)/100;
$ChangePercent = $LastPrice>0?($Change/$LastPrice)*100:0;
$ChangePercent = round($ChangePercent*100)/100;
if ($Change>=0) $sign="+";else $sign="";
if ($ChangePercent>=0) $psign="+";else $psign="";
if (!is_numeric($Open)||($Open==0&&substr($Symbolpf,0,1)=='^')) {
$Open = 'N/A';
$DayHigh = $Open;;
$DayLow = $Open;
if (is_numeric($Open)) $YearHigh = $Open;
if (is_numeric($Open)) $YearLow = $Open;
$Change = $Open;
$ChangePercent = $Open;
$sign = "";
$psign = "";
$filename = "quotes.txt";
$filepointer = fopen($filename, "w+");
fwrite($filepointer, "$Symbol" );
fclose($filepointer);
}
}
?>
<marquee height="50" width="100%"><?=$Symbol?><?=$LastPrice?><?=$sign.$Change?> (<?=$psign.$ChangePercent."%"?>)</marquee></p>


What should i do?????? I have narrowed it down. I have my symbol scrolling just cant seem to read the file. I dont know how all that reading stuff works. I just saw that you did it
View user's profile Send private message
upennballer
New Member
New Member


Joined: Jun 10, 2004
Posts: 16

PostPosted: Thu Jun 10, 2004 5:37 pm Reply with quote Back to top

NOw i have this.
But for some reason the symbol doesnt seem to be reading to the array.

Does anyone know why??


<?php
$Symbol=qqq;
$readf = @file("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=snl1d1t1c1p2va2bapomwerr1dyj1");
for($i=0; $i<7;$i++){
$filename = "quotes.txt";
$filepointer = fopen($filename, "a+");
fwrite($filepointer, "$readf[$i]" );
fclose($filepointer);
}
$readl = @file("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3");
for ($i=0;$i<count($readf);$i++) {
$read = str_replace("\"", "", $readf[$i]);
$read = explode(",", $read);
$Symbol=$read[0];
$Company=$read[1];
$LastPrice=$read[2];
$Change=$read[5];
$ChangePercent=$read[6];

$read = str_replace("\"", "", $readl[$i]);
$read = explode(",", $read);
$LastPrice=$read[2];
$Change=$read[3];
$ChangePercent=$read[4];
$Bid=$read[5];
$Ask=$read[6];
$DayHigh = $DayHigh>$LastPrice?$DayHigh:$LastPrice;
$DayHigh = $DayHigh>$Open?$DayHigh:$Open;
$DayLow = $DayLow<$LastPrice?$DayLow:$LastPrice;
$DayLow = $DayLow<$Open?$DayLow:$Open;
$YearHigh = $YearHigh>$LastPrice?$YearHigh:$LastPrice;
if (is_numeric($Open)) $YearHigh = $YearHigh>$Open?$YearHigh:$Open;
if ($changePriceMethod==1) $Change = $LastPrice>0?$LastPrice-$Open:0;
else $Change = $LastPrice>0?$LastPrice-$YesterdayClose:0;
$YearLow = $YearLow<$LastPrice?$YearLow:$LastPrice;
if (is_numeric($Open)) $YearLow = $YearLow<$Open?$YearLow:$Open;
$Change = round($Change*100)/100;
$ChangePercent = $LastPrice>0?($Change/$LastPrice)*100:0;
$ChangePercent = round($ChangePercent*100)/100;
if ($Change>=0) $sign="+";else $sign="";
if ($ChangePercent>=0) $psign="+";else $psign="";
}
?>
<marquee height="50" width="100%"><?=$pfSymbol?><?=$LastPrice?><?=$sign.$Change?> (<?=$psign.$ChangePercent."%"?>)</marquee></p>
View user's profile Send private message
upennballer
New Member
New Member


Joined: Jun 10, 2004
Posts: 16

PostPosted: Thu Jun 10, 2004 7:02 pm Reply with quote Back to top

Shortened it to this. Still doesnt work. LOL. Could Anyone Help Me out? THANKS



<?php
$Symbol=qqq;
$readl = fopen("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3", "r");
fclose("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3");
for ($i=0;$i<8;$i++) {
$read = str_replace("\"", "", $readl[$i]);
$read = explode(",", $read);
$Symbol=$read[0];
$LastPrice=$read[2];
$Change=$read[3];
$ChangePercent=$read[4];
}
?>
<marquee height="50" width="100%"><?=$Symbol?><?=$LastPrice?>--<?=$Change?>--<?=$ChangePercent?></marquee></p>
View user's profile Send private message
upennballer
New Member
New Member


Joined: Jun 10, 2004
Posts: 16

PostPosted: Thu Jun 10, 2004 7:18 pm Reply with quote Back to top

CHANGED AGAIN STILL DOESNT WORK. LOL. Please Help if possible. HitsFan

<?php
$Symbol='qqq';
$url = "http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3";
//echo $url;
//if(file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3")){
//if( fopen("$url", "r")){
// echo "file works";
//}else{
// echo "LIFE SUCKS!!";
//}
$readl= @file("$url");
echo $readl;
for ($i=0;$i<8;$i++) {
$read = str_replace("\"", "", $readl[$i]);
$read = explode(",", $read);
$Symbol=$read[0];
$LastPrice=$read[2];
$Change=$read[3];
$ChangePercent=$read[4];
}
?>
<marquee height="50" width="100%"><?=$Symbol?><?=$LastPrice?>--<?=$Change?>--<?=$ChangePercent?></marquee></p>
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 15057
Location: Kansas

PostPosted: Thu Jun 10, 2004 10:25 pm Reply with quote Back to top

upennballer wrote:
Also a bug. When showing what an index does for the day or a stock for that matter it shows the price change from the open. It should show price change from previous close.

Thanks
No, that's not a bug. I had stock traders and analysts look at this before it was ever released. If you look in the documentation in the index.php file, you will find this
Code:
// Calculation Method for Changes in Prices.
/* Some want difference based on Open/Closing Prices some want differences based on Previous day's close and Current day's close. */
// 1 = OpenPrice - LastPrice
// 2 = YesterdayClose - LastPrice
$changePriceMethod = 1;
There are at least 2 accepted ways for calculating this.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
upennballer
New Member
New Member


Joined: Jun 10, 2004
Posts: 16

PostPosted: Thu Jun 10, 2004 10:48 pm Reply with quote Back to top

Definetly you told me that. Just trying to figure out how you got the information for that site into a variable. Doesnt seem to work for me.
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 15057
Location: Kansas

PostPosted: Thu Jun 10, 2004 11:07 pm Reply with quote Back to top

If I'm understanding you correctly, you want to loop through a series of symbols and then display those symbols and additional information in a ticker. Assuming that to be the case, you need to append each new iteration to the last. Something like this. This is just an example and the variable names are not correct. It's just to give you the concept.
Code:
//* start loop
$data = '';
for ($i=0;$i<count($symbolArray);$i++) {
  //* extract data
  $data .= $Symbol."  --  ".$LastPrice."<br />";
}
?>
<marquee height="50" width="100%"><?=$data;?></marquee></p>
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
upennballer
New Member
New Member


Joined: Jun 10, 2004
Posts: 16

PostPosted: Thu Jun 10, 2004 11:11 pm Reply with quote Back to top

k that makes sense but for some odd reason i cant seem to get the site to even store the information for one quote.

$readl= @file("$url");

doesnt work. For some reason it doesnt want to save it to readl have no clue why. I had some php people working on it and they couldnt figure it out. So i brought it to the creator. LOL. Thanks for the continued help. Once i figure this out i can make a sweet Stock ticker.
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 15057
Location: Kansas

PostPosted: Thu Jun 10, 2004 11:21 pm Reply with quote Back to top

This requires that your php installation allows for opening URL's as files. Check your phpinfo to be sure that this setting is ON=1;

allow_url_fopen = On

If it is, then this is more than "support" Laughing Support means supporting the script when there are problems or quick fixes. I will be happy to give you a quote for customizing the script Smile, but quite honestly I have given about as much 'pseudo' direction as I can.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2008 by Raven
Proud to be listed at Lobo Links Web Directory

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::

:: fisubice Theme Recoded To 100% W3C CSS & HTML 4.01 Transitional Compliance by Raven and 64bitguy ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum