I have a function to count how many rows in various tables.

 

function myCount($table,$where,$data,$type,$is,$name)

{

            global $theDate;

            if ($where == 1)

            {

                        $mysql = "SELECT COUNT(*) FROM `$table` WHERE
`$data` $is '$type'";

            } else {

                        $mysql = "SELECT COUNT(*) FROM `$table`";

            }

            echo $mysql.'<br />';

            $results = mysql_query($mysql) or die(mysql_error);

            $myRow = mysql_fetch_array($results);

            return "Total # of ".$name." = ".$myRow[0]."<br /><br />\n";

}

 

it works fine like this:

 

echo myCount('bands','1','type','promoter','=','Promoters');

 

but this will not:

$theDate = date("Ymd");

echo myCount('calendar','1','mydate','$theDate','>=','Events');

 

the sql statement comes out like this:

 

SELECT COUNT(*) FROM `calendar` WHERE `mydate` >= '$theDate'

 

Can someone please let me know what I am doing wrong?



[Non-text portions of this message have been removed]



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to