473,413 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

How to count database value

250 100+
I want to get the some of all values in given date range. This is my code and it prints all data correctly. But couldn't get the sum. Please tell me what is wrong?

[PHP]$q = mysql_query("SELECT * FROM db WHERE SID = '$SID' AND Date BETWEEN '$DateFrom' AND '$DateTo'");
//echo $Date;
while($row = mysql_fetch_array($q)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$Riml=$row["Rim"];
count ($Rim);
echo $Rrim;

}

}[/PHP]
Apr 11 '08 #1
1 1572
Markus
6,050 Expert 4TB
I want to get the some of all values in given date range. This is my code and it prints all data correctly. But couldn't get the sum. Please tell me what is wrong?

[PHP]$q = mysql_query("SELECT * FROM db WHERE SID = '$SID' AND Date BETWEEN '$DateFrom' AND '$DateTo'");
//echo $Date;
while($row = mysql_fetch_array($q)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$Riml=$row["Rim"];
count ($Rim);
echo $Rrim;

}

}[/PHP]
I think mysql_num_rows() is what you're after:
[php]
$_query =
mysql_query("
SELECT
*
FROM
`tbl_name`
WHERE
`tbl_col`
=
'{$_something}'
"; # lets say this affects 4 rows in the table `tbl_name`

$_num_rows = mysql_num_rows($_query)

echo "Rows affected: {$_num_rows}";
[/php]
Apr 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Matt | last post by:
In ASP page, if we want to retrive the number of rows in database: should we use recordset object? Since this is not update, insert, delete, or select statement sqlStmt = "SELECT COUNT(*) from...
3
by: thomasp | last post by:
I am trying to get a record count of a PHP query on a MS Acess database using ODBC with a DSN for MS ACCESS connection. I got this code from the PHP manual user notes. It seems to return the...
2
by: L Mehl | last post by:
Different users of the app will want or not want to see report footer ( appears as a separate page). I can make the section invisible with a DLookup of a Y or N value from a 'parameters' table ...
4
by: Alec Christie | last post by:
Hi All, I want to Count the number of members in my database that have specific criteria, such as Blue eyes, or Brown hair. I have fields named Hair and Eyes, and others ofcourse, but I just...
1
by: Greg Smith | last post by:
I am trying to write a SQL query that will return a record count to my C# application. I wrote the following query: ALTER PROCEDURE up_justification_duplicate AS SELECT COUNT(*) FROM...
0
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get...
0
by: tania | last post by:
i have this table in my database: CREATE TABLE FILM( F_ID INT(5) NOT NULL AUTO_INCREMENT, F_TITLE VARCHAR(40) NOT NULL, DIRECTOR_FNAME VARCHAR(20) NOT NULL, DIRECTOR_LNAME VARCHAR(20) NOT NULL,...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
13
by: craigchalmers | last post by:
Hi I am a complete novice so hope someone can shed some light on my problem/goal. I have an access database with some records in it. i have two fields 1) ArrivalDate 2) ReturnDate
8
by: Gilles Ganault | last post by:
Hello I'm trying to use the APSW package to access a SQLite database, but can't find how to check if a row exists. I just to read a tab-separated file, extract a key/value from each line, run...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.