Advertisement

09.30.2008 at 09:41PM PDT, ID: 23776960 | Points: 500
[x]
Attachment Details

PHP loop and timing... + database update.

Asked by cstormer in PHP Scripting Language, PHP and Databases, Web Services

Tags:

I am building an online portfolio tool... it interacts with yahoo finance.

I basically have 10 symbols in a database, I would like to loop through the database starting at symbol the first value drop it into the below code, when it returns the value, I would like to take the values of the array and update the database based on these values.  

Company Name: <?=$read[0];?>
Stock Symbol: <?=$read[1];?>
Exchange: <?=$read[2];?>
Current Stock Price: <?=$read[3];?>
Declared Dividend: <?=$read[14];?>

So basically I want query yahoo, get the result and update my database until there are no more stocks to update.   If possible I would like the process to do one about every 15 seconds and than move to the next, when finished start over at the beginning again.

The database fields are:
`company`<-- Company Name
`exchange` <-- Exchange
`price` <-- Price
`stock_index` <-- Symble
'dividend' <-- dividend

So the field that is used for the original query is stock_index, I need to loop through that and use it to update the others.


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
<?php
	$open = fopen("http://quote.yahoo.com/d/quotes.csv?s=$search&f=nsxl1copmwrj1t8eyd&e=.csv", "r");
	$read = fread($open, 2000);
	fclose($open);
	$read = str_replace("\"", "", $read);
	$read = explode(",", $read);
	//print_r($read) ;
?>
[+][-]09.30.2008 at 10:40PM PDT, ID: 22611858

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.01.2008 at 05:15AM PDT, ID: 22613415

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.01.2008 at 05:57AM PDT, ID: 22613687

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628