count

Limit download count with text file in PHP

if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['download']==='1') { $handle = fopen('lastdownload.txt','rw'); $date = @fread($handle,filesize('lastdownload.txt')); if (time() - 30 * 60 > $date) { fwrite($handle,time()); header('Content-type: application/zip'); header('Content-Disposition: attachment; filename="dwnld_'.date('d_m_Y...

Proper way for count empty variables

Hi, I use kohana and when you try to fetch data from database it returns class variables(like $user->firstname) as a database data. User table have a 12 columns and i fetch 8 columns but at this point some of columuns maybe empty(like $user->phone). How can i found empty column number ?(Proper way..) Thanks A Lot ...

Time counter with Javascript or PHP

Hello, I'm a PHP programmer...done some study on google and tried it, but didn't get the output i need Users will enter the time in the textbox provided...now i need to give them counter from the time they entered ? Example : If i enter 1:27:38 and click on submit then time should get decreased and i shud get alert when it reaches to...

How to count with 0

I want to count with 0. I means if $x = 002 $y = 999 Now I want to count it by keep the 00. for ( $i = $x ; $i <= $y; $i++ ) { echo $i; } but it echo - 002, 3, 4, 5 I want it to count by keep the 00. as like 005, 006, 007, 008, 009, 010, 011, 012. Please help me. I need it. Thanks ...

How can I speed up a count(*) which is already using indexes? (MyISAM)

I have a 3 large tables (10k, 10k, and 100M rows) and am trying to do a simple count on a join of them, where all the joined columns are indexed. Why does the COUNT(*) take so long, and how can I speed it up (without triggers and a running summary)? mysql> describe SELECT COUNT(*) FROM `metaward_alias` INNER JOIN `metaward_achiever` ON ...

COUNT with DATE INTERVALS

I have this table called Table1 as follows: UserID Date 1 01/01/09 1 14/01/09 1 25/01/09 1 01/02/09 1 15/02/09 2 02/02/09 2 15/02/09 I am trying to return a result that counts the number of times between the MIN(Date) and 30 days after the MIN(Date) wh...

mysql counts in a group by

Say I have a voting table, where users can vote on values up, down, or flat. Say a user gets a point each time the corrcet projection is made. At the end of each week I want to display some statistics. Something like: SELECT user_id, sum( user_points ) as sum_points FROM voting_results WHERE voting_date > ('2009-09-18' - INTERVAL 1 WE...

Javascript Counting Array of Objects

I am been having trouble counting the number of objects in this array in server-side javascript. Below is a JSON object which was parsed out using the array that I am trying to count. NOTE: The object is in object form, not JSON string form. JSON Object: [{"dataSymbol":"21135103","isHoliday":false,"isIPO":false,"lastTradeTime":400...

SQL query need to get user where program column includes certain program

Let me try to explain this to the best of my ability: I have a table in which there is a userID column and a program column (along with other columns of non importance). I need to find the users within this table that have multiple instances within this table where that user has a program of X associated with it. Can anyone help me ple...

Having trouble with SQL COUNT

I'm using MS SQL 2008 and I have a table of statuses (id, name) and a table of items (id, name, statusid, deleted). I want to count the number of items with each status, and have the following query: SELECT status.id, ISNULL(COUNT (items.name), 0) AS 'count' FROM status LEFT OUTER JOIN items ON items.statusid = status.id GROUP BY statu...

how do i count Href using jquery

hi all, I want to count the Href in a page using Jquery . Just for refrence: i have random number of hyperlinks in a page for each user and all hrefs are diffrentiated with thier id eg. user_1,user_2,.... so here im unable to call the function on onclick event using Jquery since each href is has different name and cannot also write s...

MySQL count() problem

Setup: create table main(id integer unsigned); create table test1(id integer unsigned); create table test2(id integer unsigned); insert into main(id) value(1); insert into test1(id) value(1); insert into test1(id) value(1); insert into test2(id) value(1); insert into test2(id) value(1); insert into test2(id) value(1); Using: ...

How can I count runs in R?

In R, what would be the most efficient/simplest way to count runs of identical elements in a sequence? For example, how to count the numbers of consecutive zeros in a sequence of non-negative integers: c(1,0,0,0,1,0,0,0,0,0,2,0,0) should give 3,5,2. Thanks. ...

How to make LEFT JOIN work with grouping/count in MySQL?

I have a query like this: SELECT type.id, type.name, COUNT(*) AS tot FROM page LEFT JOIN type ON page.type=type.id GROUP BY type.id However, this doesn't select all the types: it misses out any types that are not in the page table yet. I just want it to list every type with a number representing how many pages have that type, includin...

iPhone dev - NSTimer accuracy for time instead of recalculating?

I have a little project that is a timer that counts down 'til midnight, and I was wondering If I should leave it as it is, calculating the time until midnight each second (inside NSTimer method that gets called every 1 second): NSDate *now = [[NSDate alloc] init]; NSDateComponents *dateComponents = [[self gregorian] components: (NS...

SQL JOIN+COUNT QUERY

Hi, I'm trying to display a table showing a list of courses. I would like to include a column which shows the number of people who have completed the course and if possible, also the number who have yet to complete it. My table structure is like so: Courses courseid | title | etc Studying courseid | studentid | some other fields | ha...

[Album Count Issue] : addFilterPredicate PROBLEM with 3.1

I'm currently using the below code in one of my applications. It works great on a device running 3.0 but now always returns an Album count of 0 for each Playlist if the device is 3.1. Please let me know if I'm doing this incorrectly. I'm basically try to loop through the Playlists and count the number of Albums and Tracks for each one ...

Mysql performance and Count(*)

I want to know that my sql execute count queries in linear time or in log(n) time i think that if query parameter was indexed it can do it by cubing ...

Quickest way to Count the amount of numbers in a string, plus how to test PHP performance?

I need the best way of finding how many numbers in a string, would I have to first remove everything but numbers and then strlen? Also how would I go about testing the performance of a any PHP script I have written, say for speed and performance under certain conditions? UPDATE say I had to inlcude ½ half numbers, its definetly preg t...

SQL query with count and case statement

i need to find how many people have filed (fil_dt) their tax return within 60 days, withing 120 days, within 180 days, over 180 days of their filing period end date (fpe) for 3 different years (2006, 2007, 2008) the statement below will give me ALL years i need a count for each year and for each possibility.. anyway i can do this withou...