TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   count/select if.. (http://www.talkphp.com/general/6370-count-select-if.html)

lanez89 09-14-2012 02:27 PM

count/select if..
 
Hi, I have the following code:

PHP Code:

$zapytanie1 "SELECT * FROM `community_challenges` where status=1 and type='bet'";
     
$dzialaj1=mysql_query($zapytanie1);

    while (
$pole1 mysql_fetch_array($dzialaj1))
    {
$zapytanie2 "SELECT * FROM community_matches inner join community_bets on community_matches.datetime between '{$pole1['date_start']}' and '{$pole1['date_finish']}' and community_matches.active=0 and community_bets.matchid=community_matches.id and community_bets.users_id={$pole1['home_id']} and community_bets.status=1 and community_bets.won='y' order by community_bets.id desc limit 10";
     
$dzialaj2=mysql_query($zapytanie2); 

I need to select only first 10 records between those dates (date_start and date_finish) and I need to count number of rows, where community_bets.won="y" in first 10 records. The following code always = 10 because it selects only won bets. I tried to delete the statement community_bets.won='y' and something like this:

PHP Code:

$i=0;
if (
$pole2['won'] == "y") { $i++;} 

but it doesn't work. "$zapytanie2" checks more than 1 records, because it's in "while loop"


All times are GMT. The time now is 09:48 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0