sim tech |
03-29-2005 03:07 PM |
Quote:
Originally Posted by interfx
Great add-on... Anyone figure out to add the actual company name yet???
|
Would this work? This is what I did, but I'm having problems having it write to the table & then xfer to the template.
I created a field in the stocks table in MySQL called 'comapnyname' and then modded the admin file so that it would write the company name to the table. (see image). It's close but no cigar yet. Do I have to make 'companyname' a global? Also - no data in the table as of yet. Anyone?? Thanx
PHP Code:
<?PHP
///////////////////////////////////
//vB Stocks(1.0.0) by Antonbomb22//
//Code Basis by joeaic/////////////
//May not be redisitributed,copied/
//or modifed without permission////
///////////////////////////////////
require_once('./global.php');
if(empty($_REQUEST['do']))
{
$_REQUEST['do']="showstocks";
}
if($_REQUEST['do']=="showstocks")
{
print_cp_header("Stock Manager");
print_table_start();
print_table_header("Manage Stocks", 3);
print_cells_row("stocksymbol", "Stock Status", "stocktitle", "companyname", "Stock Options", 1, '', -1);
$getstocks= $DB_site->query("SELECT stockname,active FROM ".TABLE_PREFIX."stocks");
while($stock= $DB_site->fetch_array($getstocks))
{
if($stock['active']==1)
{
$status= "Active";
}
else
{
$status= "Inactive";
}
print "<tr class=\"".fetch_row_bgclass()."\"><td><a href=\"http://finance.yahoo.com/q?s=".$stock['stockname']."\">".$stock['stockname']."</a></td><td>".$status."</td><td>[<a href=\"stocksmanager.php?do=edit&sym=".$stock['stockname']."\">Edit</a>][<a href=\"stocksmanager.php?do=delete&sym=".$stock['stockname']."\">Delete</a>]</td></tr>";
}
print_table_footer();
}
if($_REQUEST['do']=="edit")
{
$stock= $DB_site->query_first("SELECT stockname, active FROM ".TABLE_PREFIX."stocks");
print_cp_header("Stock Edit: ".$stock['stockname']."'");
print_form_header('stocksmanager', 'update');
construct_hidden_code("origsym", $stock['stockname']);
print_table_header("Stock Edit: ".$stock['stockname']."'");
print_input_row("Stock Symbol:<dfn>example: YHOO, ^DJI, GOOG</dfn>", "stocksymbol", $stock['stockname'], "'");
// ATG stock name mod
print_input_row("Company Name:<dfn>example: Northwest Airlines</dfn>", "companyname", $stock['companyname'], "'");
print_yes_no_row("Stock Active?", "active", $stock['active']);
print_submit_row("Update Stock");
}
if($_POST['do']=="update")
{
globalize($_POST, array(
'stockname' => TEXT,
// ATG *******************************************
'companyname' => TEXT,
'active' => INT,
'origsym' => TEXT
));
$DB_site->query("UPDATE ".TABLE_PREFIX."stocks SET stockname='".addslashes($stocksymbol)."', active=".$active." WHERE stockname='".addslashes($origsym)."'");
// ATG ********************************************
$DB_site->query("UPDATE ".TABLE_PREFIX."stocks SET companyname='".addslashes($companyname). "'");
define('CP_REDIRECT', 'stocksmanager.php?do=showstocks');
print_stop_message('stock_updated_successfully');
}
if($_REQUEST['do']=="delete")
{
$DB_site->query("DELETE FROM ".TABLE_PREFIX."stocks WHERE stockname='".addslashes($sym)."'");
define('CP_REDIRECT', 'stocksmanager.php?do=showstocks');
print_stop_message('stock_deleted_successfully');
}
if($_REQUEST['do']=="add")
{
print_cp_header("Add Stock");
print_form_header('stocksmanager', 'insert');
print_table_header("Add Stock");
print_input_row("Stock Symbol:<dfn>example: YHOO, ^DJI, NWAC</dfn>", "stocksymbol");
// ATG *********************************************
print_input_row("Company Name:<dfn>example: Northwest Airlines</dfn>", "companyname");
print_yes_no_row("Stock Active?", "active", 0);
print_submit_row("Add Stock");
}
if($_POST['do']=="insert")
{
globalize($_POST, array(
'stocksymbol' => TEXT,
'active' => INT
));
$DB_site->query("INSERT INTO ".TABLE_PREFIX."stocks (stockname,active) VALUES ('".addslashes($stocksymbol)."', ".intval($active).")");
define('CP_REDIRECT', 'stocksmanager.php?do=showstocks');
print_stop_message('stock_inserted_successfully');
}
print_cp_footer();
exit;
?>
|