On Tue, 22 Jul 2003 17:08:50 -0400, you wrote:

>I am trying to count in mySQL the number of entries in the field "day" where day=2 or 
>3. 
>
>Then I want to check just to see if that returned a value greater than 0 or not.
>
>I am using the code below, but having a problem, I keep getting 0 as the total
>
>What am i doing wrong.   
>
>
>   $dbqueryshipping1 = "select *, COUNT(day) from tempuserpurchase where day=\"2\" 
> and day=\"3\" GROUP BY itemname";
>        $resultshipping1 = mysql_db_query($dbname,$dbqueryshipping1); 
> if(mysql_error()!=""){echo mysql_error();}
>       $shipping1 = mysql_fetch_array($resultshipping1);

You essentially are looking for TRUE or FALSE, right? Nothing else?

a) What's the * for?
b) day can never be 2 AND 3 at the same time. Boolean and/or usage is more
strict than English and/or usage.

Try this

function x() {
    $query = "SELECT COUNT(*) FROM tempuserpurchase WHERE day=2 OR day=3";

    [...]

    $a = mysql_fetch_row($r);

    if ($a[0]) {
        return (TRUE);
    }
    return (FALSE);
}

That should give you the core of a function that returns TRUE if there are
rows in the db where day = 2 or day = 3. Expand as you wish (eg moving the
magic numbers out of the sql query).


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to