09-14-2012, 02:27 PM
|
#1 (permalink)
|
|
The Visitor
Join Date: Sep 2012
Posts: 1
Thanks: 0
|
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"
|
|
|
|