0){ $shop_id = $_GET['shop_id']; } else { $shop_id =0;} switch ($_GET['error']) { case 'no_shop': $error_message = 'ERROR: A Shop at this location for today does not exist: Start New Shop'; break; case 'new_error_message': //this is a sample error message. insert error case here $error_message = ''; break; default: $error_message = 'Start a New Shop OR View an Existing Shop'; break; } //shop_date if($_GET['shop_date']>0){ $shop_date = $_GET['shop_date']; } else { $shop_date =current_datetime();} //dayname if($_GET['shop_dayname']=='alldays'){ $shop_dayname = ''; } elseif(isset($_GET['shop_dayname'])) { $shop_dayname = "AND DAYNAME(date) = '" . $_GET['shop_dayname'] . "'"; } else { $shop_dayname = ''; } //record_count if($_GET['record_count']>0){ $record_count = $_GET['record_count']; } else { $record_count = 10;} $ctrl_shoplocation = "ctrl_shoplocation"; $ctrl_shoptype = "ctrl_shoptype"; $editFormAction = $_SERVER['PHP_SELF'] . "?shop_date=$shop_date&shop_id=$shop_id"; $editFormAction_no_shopid = $_SERVER['PHP_SELF'] . "?shop_date=$shop_date"; mysql_select_db($database_YBDB, $YBDB); $query_Recordset1 = "SELECT shops.shop_id, date, DAYNAME(date) as day ,shop_location, shop_type, ip_address, IF(SUBSTRING(date,1,10) = curdate(),1,0) AS CanEdit, COUNT(DISTINCT contact_id) AS num_visitors, ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS total_hours FROM shops LEFT JOIN shop_hours ON shops.shop_id = shop_hours.shop_id WHERE date <= '{$shop_date}' {$shop_dayname} GROUP BY shop_id ORDER BY date DESC , shop_id DESC LIMIT 0, $record_count;"; $Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error()); //$row_Recordset1 = mysql_fetch_assoc($Recordset1); //Wait to fetch until do loop $totalRows_Recordset1 = mysql_num_rows($Recordset1); // action on submit if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_new")) { $insertSQL = sprintf("INSERT INTO shops (shop_location, shop_type, date, ip_address) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['ctrl_shoplocation'], "text"), GetSQLValueString($_POST['ctrl_shoptype'], "text"), GetSQLValueString($_POST['ctrl_date'], "date"), GetSQLValueString($_SERVER['REMOTE_ADDR'], "text")); mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($insertSQL, $YBDB) or die(mysql_error()); //determines the shop_id just added to the database mysql_select_db($database_YBDB, $YBDB); $query_Recordset2 = "SELECT MAX(shop_id) AS shop_id FROM shops;"; $Recordset2 = mysql_query($query_Recordset2, $YBDB) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); $shop_id = $row_Recordset2["shop_id"]; //the added shop_id is passed as a variable to the shop page $insertGoTo = "{$page_shop_log}?shop_id=" . $shop_id; mysql_free_result($Recordset2); header(sprintf("Location: %s", $insertGoTo)); //header(sprintf("Location: %s", "index.html")); } //Update Record isset($_POST["MM_update"]) if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit")) { $updateSQL = sprintf("UPDATE shops SET date=%s, shop_location=%s, shop_type=%s WHERE shop_id=%s", GetSQLValueString($_POST['date'], "date"), GetSQLValueString($_POST['shop_location'], "text"), GetSQLValueString($_POST['shop_type'], "text"), GetSQLValueString($_POST['shop_id'], "int")); //"2006-10-12 18:15:00" mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($updateSQL, $YBDB) or die(mysql_error()); header(sprintf("Location: %s",$editFormAction_no_shopid )); //$editFormAction } //Change Date isset($_POST["MM_update"]) if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { $editFormAction = $_SERVER['PHP_SELF'] . "?shop_date={$_POST['shop_date']}&shop_dayname={$_POST['dayname']}&record_count={$_POST['record_count']}"; header(sprintf("Location: %s",$editFormAction )); //$editFormAction } ?>
ShopID Date Shop Location Shop Type Stats Edit
Log Non-Shop Hours
Start New Shop:
 
    View Existing Shops:
Edit Record:
Shop ID: {$row_Recordset1['shop_id']}";?>
Visitors
~ Hours
Shop ID: {$row_Recordset1['shop_id']}";?> Visitors
~ Hours
edit";} else {echo " ";} ?>

Show shops on or before: Day of week: