I'm a newer user at PHP, MYSql and have taken a four day intro course. I Was using AccessVB before going down this newer web programming.
I can use the code block pasted below in the phpMyAdmin window to create a table named OutStdCnts which also get populated or records append to by the SELECT part of the code. This works in the phpMyAdmin window. I'm trying to duplicate it from within PHP code. I was able to create table with this code in php see the first code block.
But can't find how to populate the table based on the SELECT statement below second code block?
Any help would be greatly appreciated.
$sql = 'DROP TABLE IF EXISTS `OutStdCnts`'; mysql_query( $sql ); $sql = 'CREATE TABLE `outstdcnts` ( `TotalOSP` VARCHAR( 20 ) NOT NULL, `outstandingPositive` VARCHAR( 20 ) NOT NULL, `Livingunit` VARCHAR( 5 ) DEFAULT 0 NOT NULL, `Region` VARCHAR( 25 ) NOT NULL, PRIMARY KEY ( `Region` ) )'; echo 'Creating table: \'OutStdCnts\'....'; mysql_query( $sql );
CREATE TABLE IF NOT EXISTS OutStdCnts( TotalOSP varchar(20) NOT NULL , outstandingPositive Varchar( 5 ) NOT NULL DEFAULT '0', Livingunit Varchar( 35 ) NOT NULL , Region Varchar( 25 ) NOT NULL ) SELECT Region, Livingunit, outstandingPositive, COUNT( `OutstandingPositive` ) AS TotalOSP FROM clients AS c, dailylog AS d WHERE c.ID = d.ClientID AND `OutstandingPositive` <> 'NULL' AND `Region` = 'Wyndham' AND `livingunit` = 'grigg' GROUP BY `OutstandingPositive`