Hello,
I am trying to divide one value from my data table with an associated ID by another value from my data table with a different ID for the same day that the value was added to the data table.
I update my data table daily with several values that have different IDs that label the value type.
Certain of the values I add to my data table also have a value of 0. Therefore, if I want to divide one value by another, I have to ensure that the rows that contain a value of 0 are not counted.
After I divide all of the values into a new value, I then need to store that value in my data table with a new ID so that I can differentiate it.
I have some code that I've been working on but am getting tricked up at this point and would appreciate any further assistance. -
<?
-
-
function getValue ( $iPlayer, $iStat ) {
-
$sql = sprintf( "SELECT value FROM data WHERE player_id = '%d' and statistic_id = '%d' and day = CURdate()", $iPlayer, $iStat);
-
$result = mysql_query ( $sql );
-
}
-
-
function getListofPlayers ( ) {
-
$sql = 'SELECT player_id FROM data WHERE day = CURdate()';
-
$result = mysql_query ( $sql );
-
}
-
-
function storeValue ( $iPlayer, $iStat, $value ) {
-
$sql = sprintf( "INSERT INTO data SET player_id = '%d', statistic_id = '%d', value = '%s', day = NOW()", $iPlayer, $iStat, $value );
-
$result = mysql_query ( $sql );
-
}
-
-
$aPlayer = getListOfPlayers();
-
foreach ( $aPlayer as $oPlayer ) {
-
-
$stat_id_1 = 9;
-
$stat_id_2 = 4;
-
$stat_id_new = 39;
-
-
$a = getValue( $oPlayer->id, $stat_id_1 );
-
$b = getValue( $oPlayer->id, $stat_id_2 );
-
$c = $a / $b;
-
-
storeValue ( $oPlayer->id, $stat_id_new, $c );
-
-
}
-
-
?>
-
1 2635 Markus 6,050
Recognized Expert Expert
Check if the value is 0? -
if variable equals 0
-
do not divide
-
else
-
do divide
-
endif
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kevin Myers |
last post by:
Hello,
I'm an experienced application developer in some languages (including
various SQL dialects), but have very little experience with MS Access or
VBA, and am having trouble figuring out how to even get started with the
following seemingly simple task...
I have a table with a composite primary key made up of three columns. The
lowest...
|
by: Vasilis X |
last post by:
Here is the question :
I have a data table, UnShorted, which has a data column EventTime (type :
date time) and a data column Values (type : single).
I want to create a table, Shorted, that will have all values of UnShorted
but they will be shorted by EventTime.
I try this :
dim Results as New DataRow( ) = UnShorted.Select (...
|
by: Kwok |
last post by:
In my project... which deadline is July 3 ....
I need to design a very simple database....
which can enter some subject or subheading in a document to a data table in MS access.
I use VB to implement this,
tsubject <-- is the text box name
the code show as follow:
"INSERT INTO data (subject) values ("""+trim(Me.tsubject)+""");"
I think...
|
by: DH |
last post by:
I have an untyped dataset with a table. I am trying to
programmatically add a row to this table. This was working in VS 2003
/ .net 1.1 I am receiving an error "Object reference not set to an
instance of an object."
Here is the code that worked in VS 2003 / .net 1.1:
row = dtLines.NewRow()
|
by: joel |
last post by:
Hi Guys ... I need some help on this... i know i've followed the right
declarations on this.. or if not i may be close on hitting it. And i
know there's something wrong with this code.
This is what i did... it adds a new row into the data table... with
values like department, sales glcode etc. when i click the insert/add
button it creates...
| |
by: riceking |
last post by:
Is it possible to do the following and if so, how?
In one table, I have a list of email addresses I know are bad and no longer work.
Another table has a list of companies with contact people, fields accommodate up to ten people. There's a corresponding field for each one for their email address. In other words, the table has 10 different...
|
by: san1014 |
last post by:
Hi
I have a table
SQL> select * from nodes;
NODE_ID NODE_NAME
-------------------- ------------------------------
N1 Kothhapet
N2 Nagole
N3 Uppal
|
by: drwigginton |
last post by:
I have created several bar charts in MS Access using query results to provide the data for the chart. I added data tables to the charts to show the actual values. My problem is that one of the fields in the data table continues to display a number with several decimal places showing (i.e., 7.120000054). The query field that provides the number...
|
by: Mark |
last post by:
I have a table with a field that uses a combobox to populate values. The
Lookup tab within table design mode is the following:
Display Control Combo Box
Row Source Type Table/Query
Row Source SELECT .LastName, .FirstName, .EmployeeNumber FROM ;
Bound Column 3
Column Count 3...
|
by: krisssgopi |
last post by:
Hi Team,
While am using the below code it was throwing an exception update unable to find table mapping or data table customer. Please help me in this regard.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con.Open()
param.ParameterName =...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |