joined:May 23, 2012
Hello, Background information
I'm preparing a stock website where i want to give members the option to track their own stockpicks. A so called "watchist" or "track record".
I made a script where the member can enter the stockpick, whereafter the symbol and the price of the stock at that moment will be entered and stored into the database. My question
When the member wants to sell the stock, he needs to fill in a form with the ticker symbol he wants to sell and then the ticker should be stored in the database with the sell price at that single moment. The sell price should be stored in the "sell" column in the database, in the same row as the bought stock (column "buy").
How shall this script look like? Code
The table in the database is "portfolio" with rows "id", "symbol", "buy" and "sell".
This is what i have now:
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s='.$_POST['symbol'].'&f=sl1d1t1c1ohgv&e=.csv' );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );
$contents = explode( ',', str_replace( '"', '', $output ) );
echo "<p>Stock: <b>\$$contents</b> </p>";
$conn = mysql_connect("#*$!","#*$!","#*$!");
$db = mysql_select_db("#*$!",$conn);
mysql_query("UPDATE portfolio SET sell=$contents
echo “Your stock has been sold”;