PHP - Trying To Compress And Make My Code Faster
I apologize for the length of my script. Is there a better way to do some of what I am doing here? My script is working fine but it works off a lot of data and if I try to query all the results, the response is pretty slow (1500ms). I'm concerned about that length of time when it comes to multiple users hitting the server at once. I may have to limit the query with pagination, etc. But, I just have a feeling there's a better way to do what I'm doing without over 1,000 lines....
//fetch production data if( $action == 'fetch_production_data' ) { //setup query $sql = 'SELECT * FROM production_data ORDER BY enterprise, job_number, TRIM(line_item) ASC'; //execute SQL transaction try { //prepare SQL statement & execute $stmt = $pdo->prepare($sql); $stmt->execute(); //bind column names to variables $stmt->bindColumn('id', $id); $stmt->bindColumn('job_number', $job_number); $stmt->bindColumn('enterprise', $enterprise); $stmt->bindColumn('part_number', $part_number); $stmt->bindColumn('description', $description); $stmt->bindColumn('qty', $qty); $stmt->bindColumn('line_item', $line_item); $stmt->bindColumn('as400_ship_date', $as400_ship_date); $stmt->bindColumn('date_showed_on_report', $date_showed_on_report); $stmt->bindColumn('shipping_method', $shipping_method); $stmt->bindColumn('notes', $notes); $stmt->bindColumn('date_shown_complete', $date_shown_complete); $stmt->bindColumn('actual_ship_date', $actual_ship_date); $stmt->bindColumn('qty_shipped', $qty_shipped); //store user dept code $user_dept_code = get_user_dept( $_SESSION[ 'user_id' ], $pdo ); //$button = ''; //output data into spreadsheet view while($row = $stmt->fetch(PDO::FETCH_BOUND)) { //setup vars to store button HTML $btn_qc = ''; $btn_thermoforming = ''; $btn_vinylpaint = ''; $btn_finalassm = ''; $btn_crateship = ''; //store each dept status query for performance $status_qc = isset( get_order_status( $id, 10, $pdo )[0]['status_id'] ) ? get_order_status( $id, 10, $pdo )[0]['status_id'] : '0'; $status_thermoforming = isset( get_order_status( $id, 6, $pdo )[0]['status_id'] ) ? get_order_status( $id, 6, $pdo )[0]['status_id'] : '0'; $status_vinylpaint = isset( get_order_status( $id, 5, $pdo )[0]['status_id'] ) ? get_order_status( $id, 5, $pdo )[0]['status_id'] : '0'; $status_finalassm = isset( get_order_status( $id, 7, $pdo )[0]['status_id'] ) ? get_order_status( $id, 7, $pdo )[0]['status_id'] : '0'; $status_crateship = isset( get_order_status( $id, 8, $pdo )[0]['status_id'] ) ? get_order_status( $id, 8, $pdo )[0]['status_id'] : '0'; $status_msg = 'Order ' . $id .' '; //echo $status_vinylpaint . '<br>'; //build view based on user's department code switch ( $user_dept_code ) { //Design or AMS View case '4': case '9': //determine status of order for qc dept switch ( $status_qc ) { //order in progress case '1': $btn_qc = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>In Progress</button>'; break; //order delayed case '2': $btn_qc = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Delayed</button>'; break; //order finished case '3': $btn_qc = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Finished</button>'; break; //order not started case '0': default: $btn_qc = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Not Started</button>'; break; } //determine status of order thermoforming switch ( $status_thermoforming ) { //order in progress case '1': $btn_thermoforming = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>In Progress</button>'; break; //order delayed case '2': $btn_thermoforming = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Delayed</button>'; break; //order finished case '3': $btn_thermoforming = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Finished</button>'; break; //order not started case '0': default: $btn_thermoforming = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Not Started</button>'; break; } //determine status of order for vinyl & paint switch ( $status_vinylpaint ) { //order in progress case '1': $btn_vinylpaint = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>In Progress</button>'; break; //order delayed case '2': $btn_vinylpaint = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Delayed</button>'; break; //order finished case '3': $btn_vinylpaint = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Finished</button>'; break; //order not started case '0': default: $btn_vinylpaint = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Not Started</button>'; break; } //determine status of order final assembly switch ( $status_finalassm ) { //order in progress case '1': $btn_finalassm = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>In Progress</button>'; break; //order delayed case '2': $btn_finalassm = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Delayed</button>'; break; //order finished case '3': $btn_finalassm = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Finished</button>'; break; //order not started case '0': default: $btn_finalassm = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Not Started</button>'; break; } //determine status of order for crating & shipping switch ( $status_crateship ) { case '1': $btn_crateship = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>In Progress</button>'; break; //order delayed case '2': $btn_crateship = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Delayed</button>'; break; //order finished case '3': $btn_crateship = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Finished</button>'; break; //order not started case '0': default: $btn_crateship = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Not Started</button>'; break; } //break parent switch break; //Vinyl & Paint View case '5': //determine status of order for qc dept switch ( $status_qc ) { //order in progress case '1': $btn_qc = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>In Progress</button>'; break; //order delayed case '2': $btn_qc = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Delayed</button>'; break; //order finished case '3': $btn_qc = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Finished</button>'; break; //order not started case '0': default: $btn_qc = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Not Started</button>'; break; } //determine status of order thermoforming switch ( $status_thermoforming ) { //order in progress case '1': $btn_thermoforming = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>In Progress</button>'; break; //order delayed case '2': $btn_thermoforming = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Delayed</button>'; break; //order finished case '3': $btn_thermoforming = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Finished</button>'; break; //order not started case '0': default: $btn_thermoforming = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Not Started</button>'; break; } //determine status of order for vinyl & paint switch ( $status_vinylpaint ) { //order in progress case '1': $btn_vinylpaint = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5">In Progress</button>'; break; //order delayed case '2': $btn_vinylpaint = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5">Delayed</button>'; break; //order finished case '3': $btn_vinylpaint = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5">Finished</button>'; break; //order not started case '0': default: $btn_vinylpaint = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5">Not Started</button>'; break; } //determine status of order final assembly switch ( $status_finalassm ) { //order in progress case '1': $btn_finalassm = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>In Progress</button>'; break; //order delayed case '2': $btn_finalassm = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Delayed</button>'; break; //order finished case '3': $btn_finalassm = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Finished</button>'; break; //order not started case '0': default: $btn_finalassm = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Not Started</button>'; break; } //determine status of order for crating & shipping switch ( $status_crateship ) { case '1': $btn_crateship = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>In Progress</button>'; break; //order delayed case '2': $btn_crateship = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Delayed</button>'; break; //order finished case '3': $btn_crateship = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Finished</button>'; break; //order not started case '0': default: $btn_crateship = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Not Started</button>'; break; } //break parent switch break; //Thermoforming View case '6': //determine status of order for qc dept switch ( $status_qc ) { //order in progress case '1': $btn_qc = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>In Progress</button>'; break; //order delayed case '2': $btn_qc = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Delayed</button>'; break; //order finished case '3': $btn_qc = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Finished</button>'; break; //order not started case '0': default: $btn_qc = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Not Started</button>'; break; } //determine status of order thermoforming switch ( $status_thermoforming ) { //order in progress case '1': $btn_thermoforming = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6">In Progress</button>'; break; //order delayed case '2': $btn_thermoforming = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6">Delayed</button>'; break; //order finished case '3': $btn_thermoforming = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6">Finished</button>'; break; //order not started case '0': default: $btn_thermoforming = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6">Not Started</button>'; break; } //determine status of order for vinyl & paint switch ( $status_vinylpaint ) { //order in progress case '1': $btn_vinylpaint = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>In Progress</button>'; break; //order delayed case '2': $btn_vinylpaint = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Delayed</button>'; break; //order finished case '3': $btn_vinylpaint = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Finished</button>'; break; //order not started case '0': default: $btn_vinylpaint = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Not Started</button>'; break; } //determine status of order final assembly switch ( $status_finalassm ) { //order in progress case '1': $btn_finalassm = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>In Progress</button>'; break; //order delayed case '2': $btn_finalassm = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Delayed</button>'; break; //order finished case '3': $btn_finalassm = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Finished</button>'; break; //order not started case '0': default: $btn_finalassm = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Not Started</button>'; break; } //determine status of order for crating & shipping switch ( $status_crateship ) { case '1': $btn_crateship = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>In Progress</button>'; break; //order delayed case '2': $btn_crateship = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Delayed</button>'; break; //order finished case '3': $btn_crateship = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Finished</button>'; break; //order not started case '0': default: $btn_crateship = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Not Started</button>'; break; } //break parent switch break; //Derrick Donnel's View case '7,8': //determine status of order for qc dept switch ( $status_qc ) { //order in progress case '1': $btn_qc = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>In Progress</button>'; break; //order delayed case '2': $btn_qc = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Delayed</button>'; break; //order finished case '3': $btn_qc = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Finished</button>'; break; //order not started case '0': default: $btn_qc = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Not Started</button>'; break; } //determine status of order for qc dept switch ( $status_thermoforming ) { //order in progress case '1': $btn_thermoforming = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>In Progress</button>'; break; //order delayed case '2': $btn_thermoforming = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Delayed</button>'; break; //order finished case '3': $btn_thermoforming = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Finished</button>'; break; //order not started case '0': default: $btn_thermoforming = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Not Started</button>'; break; } //determine status of order for qc dept switch ( $status_vinylpaint ) { //order in progress case '1': $btn_vinylpaint = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>In Progress</button>'; break; //order delayed case '2': $btn_vinylpaint = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Delayed</button>'; break; //order finished case '3': $btn_vinylpaint = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Finished</button>'; break; //order not started case '0': default: $btn_vinylpaint = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Not Started</button>'; break; } //determine status of order for qc dept switch ( $status_finalassm ) { //order in progress case '1': $btn_finalassm = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7">In Progress</button>'; break; //order delayed case '2': $btn_finalassm = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7">Delayed</button>'; break; //order finished case '3': $btn_finalassm = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7">Finished</button>'; break; //order not started case '0': default: $btn_finalassm = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7">Not Started</button>'; break; } //determine status of order for qc dept switch ( $status_crateship ) { case '1': $btn_crateship = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8">In Progress</button>'; break; //order delayed case '2': $btn_crateship = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8">Delayed</button>'; break; //order finished case '3': $btn_crateship = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8">Finished</button>'; break; //order not started case '0': default: $btn_crateship = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8">Not Started</button>'; break; } //break parent switch break; //Final Assembly View case '7': //determine status of order for qc dept switch ( $status_qc ) { //order in progress case '1': $btn_qc = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>In Progress</button>'; break; //order delayed case '2': $btn_qc = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Delayed</button>'; break; //order finished case '3': $btn_qc = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Finished</button>'; break; //order not started case '0': default: $btn_qc = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Not Started</button>'; break; } //determine status of order thermoforming switch ( $status_thermoforming ) { //order in progress case '1': $btn_thermoforming = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>In Progress</button>'; break; //order delayed case '2': $btn_thermoforming = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Delayed</button>'; break; //order finished case '3': $btn_thermoforming = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Finished</button>'; break; //order not started case '0': default: $btn_thermoforming = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Not Started</button>'; break; } //determine status of order for vinyl & paint switch ( $status_vinylpaint ) { //order in progress case '1': $btn_vinylpaint = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>In Progress</button>'; break; //order delayed case '2': $btn_vinylpaint = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Delayed</button>'; break; //order finished case '3': $btn_vinylpaint = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Finished</button>'; break; //order not started case '0': default: $btn_vinylpaint = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Not Started</button>'; break; } //determine status of order final assembly switch ( $status_finalassm ) { //order in progress case '1': $btn_finalassm = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7">In Progress</button>'; break; //order delayed case '2': $btn_finalassm = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7">Delayed</button>'; break; //order finished case '3': $btn_finalassm = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7">Finished</button>'; break; //order not started case '0': default: $btn_finalassm = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7">Not Started</button>'; break; } //determine status of order for crating & shipping switch ( $status_crateship ) { case '1': $btn_crateship = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>In Progress</button>'; break; //order delayed case '2': $btn_crateship = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Delayed</button>'; break; //order finished case '3': $btn_crateship = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Finished</button>'; break; //order not started case '0': default: $btn_crateship = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Not Started</button>'; break; } //break parent switch break; //Crating & Shipping View' case '8': //determine status of order for qc dept switch ( $status_qc ) { //order in progress case '1': $btn_qc = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>In Progress</button>'; break; //order delayed case '2': $btn_qc = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Delayed</button>'; break; //order finished case '3': $btn_qc = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Finished</button>'; break; //order not started case '0': default: $btn_qc = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10" disabled>Not Started</button>'; break; } //determine status of order thermoforming switch ( $status_thermoforming ) { //order in progress case '1': $btn_thermoforming = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>In Progress</button>'; break; //order delayed case '2': $btn_thermoforming = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Delayed</button>'; break; //order finished case '3': $btn_thermoforming = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Finished</button>'; break; //order not started case '0': default: $btn_thermoforming = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Not Started</button>'; break; } //determine status of order for vinyl & paint switch ( $status_vinylpaint ) { //order in progress case '1': $btn_vinylpaint = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>In Progress</button>'; break; //order delayed case '2': $btn_vinylpaint = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Delayed</button>'; break; //order finished case '3': $btn_vinylpaint = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Finished</button>'; break; //order not started case '0': default: $btn_vinylpaint = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Not Started</button>'; break; } //determine status of order final assembly switch ( $status_finalassm ) { //order in progress case '1': $btn_finalassm = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>In Progress</button>'; break; //order delayed case '2': $btn_finalassm = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Delayed</button>'; break; //order finished case '3': $btn_finalassm = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Finished</button>'; break; //order not started case '0': default: $btn_finalassm = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Not Started</button>'; break; } //determine status of order for crating & shipping switch ( $status_crateship ) { case '1': $btn_crateship = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8">In Progress</button>'; break; //order delayed case '2': $btn_crateship = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8">Delayed</button>'; break; //order finished case '3': $btn_crateship = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8">Finished</button>'; break; //order not started case '0': default: $btn_crateship = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8">Not Started</button>'; break; } //break parent switch break; //Quality Control View' case '10': //determine status of order for qc dept switch ( $status_qc ) { //order in progress case '1': $btn_qc = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10">In Progress</button>'; break; //order delayed case '2': $btn_qc = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10">Delayed</button>'; break; //order finished case '3': $btn_qc = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10">Finished</button>'; break; //order not started case '0': default: $btn_qc = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10">Not Started</button>'; break; } //determine status of order thermoforming switch ( $status_thermoforming ) { //order in progress case '1': $btn_thermoforming = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>In Progress</button>'; break; //order delayed case '2': $btn_thermoforming = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Delayed</button>'; break; //order finished case '3': $btn_thermoforming = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Finished</button>'; break; //order not started case '0': default: $btn_thermoforming = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="6" disabled>Not Started</button>'; break; } //determine status of order for vinyl & paint switch ( $status_vinylpaint ) { //order in progress case '1': $btn_vinylpaint = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>In Progress</button>'; break; //order delayed case '2': $btn_vinylpaint = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Delayed</button>'; break; //order finished case '3': $btn_vinylpaint = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Finished</button>'; break; //order not started case '0': default: $btn_vinylpaint = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="5" disabled>Not Started</button>'; break; } //determine status of order final assembly switch ( $status_finalassm ) { //order in progress case '1': $btn_finalassm = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>In Progress</button>'; break; //order delayed case '2': $btn_finalassm = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Delayed</button>'; break; //order finished case '3': $btn_finalassm = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Finished</button>'; break; //order not started case '0': default: $btn_finalassm = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="7" disabled>Not Started</button>'; break; } //determine status of order for crating & shipping switch ( $status_crateship ) { case '1': $btn_crateship = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>In Progress</button>'; break; //order delayed case '2': $btn_crateship = '<button type="button" class="btn btn-danger btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Delayed</button>'; break; //order finished case '3': $btn_crateship = '<button type="button" class="btn-success btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Finished</button>'; break; //order not started case '0': default: $btn_crateship = '<button type="button" class="btn btn-secondary btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="8" disabled>Not Started</button>'; break; } //break parent switch break; //SU/Op. Mngt/Prod. Mngt View case '1': case '2': case '3': //determine status of order for qc dept switch ( $status_qc ) { //order in progress case '1': $btn_qc = '<button type="button" class="btn btn-warning btn-sm btn_change_order_status_dialog" style="margin:0; width: 100px; height:100%; font-weight: bold;" data-order-id="'. $id . '" data-order-number="'. $job_number . '" data-order-enterprise="'. $enterprise . '" data-dept-code="10">In Progress</button>'; break; //order delayed case '2': $btn_qc = '<button type="button" cla Similar TutorialsWhen I run this code it takes longer then I want to load the search results. I thought by only loading the first 30 rows it catches it would speed things up. Any ideas? I changed the $db to be 30, but only my first page painted and it was not much faster.... Code: [Select] if(!empty($keyword) && $keyword!='Zip Code') $sql="SELECT profiles.*,zipCode FROM profiles LEFT JOIN area_served ON area_served.profileId = profiles.profileId WHERE profileType!='HO' AND profiles.status='Y' $qrystr GROUP BY profiles.profileId $orderby CASE zipCode $zips_order_str , companyName asc "; else $sql="SELECT * FROM profiles LEFT JOIN area_served ON area_served.profileId = profiles.profileId WHERE profileType!='HO' and status='Y' $qrystr GROUP BY profiles.profileId $orderby "; //echo $sql; $db->query($sql); $numRows=$db->numRows(); $page->set_page_data($_SERVER[PHP_SELF],$numRows,$listing,10,true,false,true); $page->set_qry_string("searchFor=$searchFor&cat=$cat&state=$state&keyword=$keyword&distance=$distance&sorting=$sorting&listing=$listing"); $res=$db->query($page->get_limit_query($sql)); $smarty->assign('numResult',$numRows); /* show pagination */ while($row=$db->fetchAssoc($res)) { if($row['thumbnailPhoto']=='personalPhoto' || $row['thumbnailPhoto']==''){ if(!empty($row['personalPhoto'])){ $personalPhoto="profiles/".$row['personalPhoto']; $rimg->setImage($personalPhoto); $row['personalPhoto']=$rimg->resize(75,75,substr($personalPhoto,0,strpos($personalPhoto,"."))."_search"); }else{ $row['personalPhoto']="images/my-photo.gif"; } }else{ if(!empty($row['logo'])){ $personalPhoto="profiles/".$row['logo']; $rimg->setImage($personalPhoto); $row['personalPhoto']=$rimg->resize(75,75,substr($personalPhoto,0,strpos($personalPhoto,"."))."_search"); }else{ $row['personalPhoto']="images/my-photo.gif"; } } if(count($cat>0)){ $row['cat']=@implode(", ",$cat); } if(strlen($row['companyInfo'])>90){ $concat="..."; } else{ $concat=""; } $ch = curl_init(); //////////////////////////////////// //////////////////////////////////// for($cwb=1; $cwb!=$Amount; $cwb++) { $action = file_get_contents($Game."refresh_stat_manual?user_id=".$Keys[0]."&auth_key=".$Keys[1]); $xml = simplexml_load_string($action); foreach($xml->xml->viewer->user as $stats) { $energy=$stats->energy; $level=$stats->level; } if($energy <= 0 || $Stop <= $level) { echo "REACHED EITHER LEVEL $Stop OR... YOU ARE OUT OF ENERGY...\n"; sleep(100000); } $send1 = $Game."send_requests?user_id=".$IDone."&to_user_ids=".$Keys[0]."&auth_key=".$AuthOne; curl_setopt($ch, CURLOPT_URL, $send1); curl_exec($ch); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $send2 = $Game."send_requests?user_id=".$IDtwo."&to_user_ids=".$Keys[0]."&auth_key=".$AuthTwo; curl_setopt($ch, CURLOPT_URL, $send2); curl_exec($ch); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $accept = $Game."accept_all_mob_requests?user_id=".$Keys[0]."&auth_key=".$Keys[1]; curl_setopt($ch, CURLOPT_URL, $accept); curl_exec($ch); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $job = $Game."do_job?user_id=".$Keys[0]."&job_id=7200018&auth_key=".$Keys[1]; curl_setopt($ch, CURLOPT_URL, $job); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $exec1 = curl_exec($ch); if(stristr($exec1, 'You gained 6') || stristr($exec1, 'You gained 1') || stristr($exec1, 'ambulance')) { echo "#$cwb: <-- You've gained 1 ambulance... Level - ".$level." ::: ENERGY - ".$energy." :::\n"; } for($abc =1; $abc!=2; $abc++){ $remove1 = $Game."remove_mob_member?user_id=".$Keys[0]."&remove_user_id=".$IDone."&auth_key=".$Keys[1]; curl_setopt($ch, CURLOPT_URL, $remove1); curl_exec($ch); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);} for($abc =1; $abc!=2; $abc++){ $remove2 = $Game."remove_mob_member?user_id=".$Keys[0]."&remove_user_id=".$IDtwo."&auth_key=".$Keys[1]; curl_setopt($ch, CURLOPT_URL, $remove2); curl_exec($ch); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);} $sell = $Game."buy_item?user_id=".$Keys[0]."&item_id=32&amount=".$Amount."&auth_key=".$Keys[1]; curl_setopt($ch, CURLOPT_URL, $sell); $exec2 = curl_exec($ch); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if(stristr($exec2, 'sold')) { echo "::: You've sold 1 ambulance...\n"; } } curl_close(); Any idea on how I could make this faster or what I could change to make it to more efficient I read the tutorial, "Handling XML Data" and created this script from it. Excellent tutorial by the way Here is my script: Code: [Select] <?php // load SimpleXML $fx = new SimpleXMLElement('http://www.boj.org.jm/uploads/fxrates.xml', null, true); echo '<table><tr class="fx_header"><th class="fx_date">'; echo $fx->US[0]->DATE; echo '</th><th class="fx_buy">Buy</th><th class="fx_sell">Sell</th></tr><tr class="fx_us"><td class="fx_legend">USD (&#36;)</td><td class="fx_buy_sell">&#36;'; echo $fx->US[0]->BUY; echo '</td><td class="fx_buy_sell">&#36;'; echo $fx->US[0]->SELL; echo '</td></tr><tr class="fx_cad"><td class="fx_legend">CAD (&#36;)</td><td class="fx_buy_sell">&#36;'; echo $fx->CAD[0]->BUY; echo '</td><td class="fx_buy_sell">&#36;'; echo $fx->CAD[0]->SELL; echo '</td></tr><tr class="fx_gbp"><td class="fx_legend">GBP (&#163;)</td><td class="fx_buy_sell">&#36;'; echo $fx->GBP[0]->BUY; echo '</td><td class="fx_buy_sell">&#36;'; echo $fx->GBP[0]->SELL; echo '</td></tr></table>'; ?> This is the XML file that the script is reading from: http://www.boj.org.jm/uploads/fxrates.xml This is the result page (which is just the way it should look): http://projects.wstudiographics.com/ewl/boj/fxrates.php It works very well, but it take a bit of time to return the result. I think it's because of how the XML file data was set up. The thing is that I have no control over the xml data. I am only allowed to read it. I only need the first or rather latest instance of the data. Any help on this will be greatly appreciated. Thanks in advanced. Winchester (WStudio) Hello, everyone: I'm using PHP and Mysql. I've got a table of that has 30 fields that I need to add together. I've got to do this for each record, and there are about 10,000 records. Which would be more efficient? SELECT SUM( field1 + field2...) or to make an array for the fields and then use array_sum() Thanks. i need this code to execute faster, is there a faster way? function all_word_combinations($all_words_unknown,$previous_string=''){ $all_words_2=array(); if(is_array($all_words_unknown)){ $all_words_array=$all_words_unknown; }else{ $all_words_array=explode(' ',trim($all_words_unknown)); } $item2remove='the'; $all_words_array=explode(' ',trim(str_replace($item2remove.' ','',str_replace(' '.$item2remove,'',(implode(' ',$all_words_array)))))); if(count($all_words_array)>1){ $previous_array=explode(' ',$previous_string); foreach($all_words_array as $one_word){ if(!in_array($previous_string.$one_word,$all_words_2) && !in_array($one_word,$previous_array)){ $all_words_2[$previous_string.$one_word]=$previous_string.$one_word; $all_words_2=array_merge($all_words_2,all_word_combinations($all_words_array,$previous_string.$one_word.' ')); } } return $all_words_2; }else{return $all_words_array;} } $one_word_combination=''; foreach(all_word_combinations('cat dog mouse turtle shark whale elephant giraffe lion tiger fish monkey') as $one_word_combination){echo str_replace(' ','-',$one_word_combination).'<br />';} Hi! I need a "very simple" PHP script which can compress a directory and all its multi-(infinite)level sub-directories using with .tar and .gz I have tried many complex scripts so far which don't work as most of them use ZIP and I don't have access to ZIP And a few of the simple ones, just don't function. Please help! Thank you ! - Xeirus. my code: Code: [Select] echo $Profile['display']; ECHO's out: 0|1|0|1 Now I want to explode these, which is easy Code: [Select] $display = explode("|", $Profile['display']); But Now I want to use a php function to check if any of the array's = "1" and have the value set to $value= "checked"; I could do this by doing Code: [Select] if ($display['0'] == "1"){ $value = "checked"; } and then 1 2 3 and so on.. but I want a faster way, maybe a for loop, or a simpliar easier way to just check if each array = 1, make $value = checked Possible right? this is my script it gets the values form the database and adds them and saves it to a variable which is then echoed to the user before i typed this code 10 more times changing every variable name i was wondering if their was a more efficient way of doing this Code: [Select] <?php $adam_view_query = "SELECT * FROM pinkpanther_stats WHERE Player = 'Adam' ORDER BY Day_Played DESC"; $adam_view_results = mysql_query($adam_view_query) or die("Query failed ($adam_view_query) - " . mysql_error()); $adam_view_numrows = mysql_num_rows($adam_view_results); $adam_gli_query = "SELECT SUM(GLI) AS 'adam_gli' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_gli_results = mysql_query($adam_gli_query) or die ("Query failed ($adam_gli_query) - " . mysql_error()); $adam_gli_row = mysql_fetch_array($adam_gli_results); $adam_gli = $adam_gli_row['adam_gli']; $adam_goals_query = "SELECT SUM(Goals) AS 'adam_goals' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_goals_results = mysql_query($adam_goals_query) or die ("Query failed ($adam_goals_query) - " . mysql_error()); $adam_goals_row = mysql_fetch_array($adam_goals_results); $adam_goals = $adam_goals_row['adam_goals']; $adam_saves_query = "SELECT SUM(Saves) AS 'adam_saves' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_saves_results = mysql_query($adam_saves_query) or die ("Query failed ($adam_saves_query) - " . mysql_error()); $adam_saves_row = mysql_fetch_array($adam_saves_results); $adam_saves = $adam_saves_row['adam_saves']; $adam_sog_query = "SELECT SUM(SOG) AS 'adam_sog' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_sog_results = mysql_query($adam_sog_query) or die ("Query failed ($adam_sog_query) - " . mysql_error()); $adam_sog_row = mysql_fetch_array($adam_sog_results); $adam_sog = $adam_sog_row['adam_sog']; $adam_assists_query = "SELECT SUM(Assists) AS 'adam_assists' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_assists_results = mysql_query($adam_assists_query) or die ("Query failed ($adam_assists_query) - " . mysql_error()); $adam_assists_row = mysql_fetch_array($adam_assists_results); $adam_assists = $adam_assists_row['adam_assists']; $adam_ck_query = "SELECT SUM(CK) AS 'adam_ck' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_ck_results = mysql_query($adam_ck_query) or die ("Query failed ($adam_ck_query) - " . mysql_error()); $adam_ck_row = mysql_fetch_array($adam_ck_results); $adam_ck = $adam_ck_row['adam_ck']; $adam_yc_query = "SELECT SUM(YC) AS 'adam_yc' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_yc_results = mysql_query($adam_yc_query) or die ("Query failed ($adam_yc_query) - " . mysql_error()); $adam_yc_row = mysql_fetch_array($adam_yc_results); $adam_yc = $adam_yc_row['adam_yc']; $adam_rc_query = "SELECT SUM(RC) AS 'adam_rc' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_rc_results = mysql_query($adam_rc_query) or die ("Query failed ($adam_rc_query) - " . mysql_error()); $adam_rc_row = mysql_fetch_array($adam_rc_results); $adam_rc = $adam_rc_row['adam_rc']; $adam_goalie = ""; if (isset($_POST['adam_go'])) { $adam_view = mysql_real_escape_string($_POST['adam_statview']); if ($adam_view == "Total"){ $adam_gli_query = "SELECT SUM(GLI) AS 'adam_gli' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_gli_results = mysql_query($adam_gli_query) or die ("Query failed ($adam_gli_query) - " . mysql_error()); $adam_gli_row = mysql_fetch_array($adam_gli_results); $adam_gli = $adam_gli_row['adam_gli']; $adam_goals_query = "SELECT SUM(Goals) AS 'adam_goals' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_goals_results = mysql_query($adam_goals_query) or die ("Query failed ($adam_goals_query) - " . mysql_error()); $adam_goals_row = mysql_fetch_array($adam_goals_results); $adam_goals = $adam_goals_row['adam_goals']; $adam_saves_query = "SELECT SUM(Saves) AS 'adam_saves' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_saves_results = mysql_query($adam_saves_query) or die ("Query failed ($adam_saves_query) - " . mysql_error()); $adam_saves_row = mysql_fetch_array($adam_saves_results); $adam_saves = $adam_saves_row['adam_saves']; $adam_sog_query = "SELECT SUM(SOG) AS 'adam_sog' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_sog_results = mysql_query($adam_sog_query) or die ("Query failed ($adam_sog_query) - " . mysql_error()); $adam_sog_row = mysql_fetch_array($adam_sog_results); $adam_sog = $adam_sog_row['adam_sog']; $adam_assists_query = "SELECT SUM(Assists) AS 'adam_assists' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_assists_results = mysql_query($adam_assists_query) or die ("Query failed ($adam_assists_query) - " . mysql_error()); $adam_assists_row = mysql_fetch_array($adam_assists_results); $adam_assists = $adam_assists_row['adam_assists']; $adam_ck_query = "SELECT SUM(CK) AS 'adam_ck' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_ck_results = mysql_query($adam_ck_query) or die ("Query failed ($adam_ck_query) - " . mysql_error()); $adam_ck_row = mysql_fetch_array($adam_ck_results); $adam_ck = $adam_ck_row['adam_ck']; $adam_yc_query = "SELECT SUM(YC) AS 'adam_yc' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_yc_results = mysql_query($adam_yc_query) or die ("Query failed ($adam_yc_query) - " . mysql_error()); $adam_yc_row = mysql_fetch_array($adam_yc_results); $adam_yc = $adam_yc_row['adam_yc']; $adam_rc_query = "SELECT SUM(RC) AS 'adam_rc' FROM pinkpanther_stats WHERE Player = 'Adam'"; $adam_rc_results = mysql_query($adam_rc_query) or die ("Query failed ($adam_rc_query) - " . mysql_error()); $adam_rc_row = mysql_fetch_array($adam_rc_results); $adam_rc = $adam_rc_row['adam_rc']; $adam_goalie = ""; }else{ $adam_stats_query = "SELECT * FROM pinkpanther_stats WHERE Player = 'Adam' AND Day_Played = '$adam_view'"; $adam_stats_results = mysql_query($adam_stats_query) or die ("Query failed ($adam_stats_query) - " . mysql_error()); $adam_stats_row = mysql_fetch_array($adam_stats_results); $adam_goalie_test = $adam_stats_row['Goalie']; $adam_gli = $adam_stats_row['GLI']; $adam_goals = $adam_stats_row['Goals']; $adam_saves = $adam_stats_row['Saves']; $adam_sog = $adam_stats_row['SOG']; $adam_assists = $adam_stats_row['Assists']; $adam_ck = $adam_stats_row['CK']; $adam_yc = $adam_stats_row['YC']; $adam_rc = $adam_stats_row['RC']; if ($adam_goalie_test == 1){ $adam_goalie = "Yes"; }else{ $adam_goalie = "No"; } } } ?> Hi all I wonder if you could give me some advice. I basically have a mysql database of staff who work at a college, I have a front which displays details of a staff member, I grab the details using userdetails.php?id=44 (44 being the ID of the staff member) One field I have in my MySQL database is "title", which is basically Mr Ms Mrs Miss Dr At the moment, I store the "title" value in the database as "CHAR", so it appears as "Mrs" for example when I print print $row['title']; What I want to know is, which is the best method of storing and getting this data. Is it best to ----------------------------------------------------- 1: Continue as I am and keep text values in the database stored as CHAR[/li][/list] ----------------------------------------------------- 2: Change it so that instead of storing "Mr", "Dr" as CHAR, I would store them as numeric values, so; 2 would be Mr 3 would be Mrs 4 would be Dr then do a if($row['title'] == 2) { print "Mr"; } elseif($row['title'] == 3) { print "Mrs"; } elseif($row['title'] == 4) { print "Dr"; } ----------------------------------------------------- 3: Change it so that instead of storing "Mr", "Dr" as CHAR, I would store them as numeric values, but then have another database table which holds what value each number is, so my new database table would be like --- title_values ---- id value 2 Mr 3 Mrs 4 Dr ------------------------- then on the front end, do a SELECT such as SELECT `value` FROM `title_values` WHERE `id` = "'.$row['id'].'" I guess the advantage to this one, is that I can modify the list of titles and expand it. ----------------------------------------------------- which of those is generally considered better? faster? and less server intensive? or is there a better way to do it? Thanks very much Hi everyone. Please help me please. I'm just learning PHP. There was a task, I completed it, but they sent a response that it needs to be modified. You need to make changes: "When saving data, you need to take into account the keys of the new data and the data stored in the database(file), if the value with the key in the database(file) already exists, then you need to replace its value with a new one." and "The FileBox and DbBox classes should be implemented in such a way that you can not create more than one instance of each of the classes." Googled and came across what i need to apply the singleton pattern. <?php interface Box { public function setData($key, $value); public function getData($key); public function save(); public function load(); } abstract class BoxAbstract implements Box { protected $data = []; public function setData($key, $value) { $this->data[$key] = $value; } public function getData($key) { return $this->data[$key] ?? null; } public abstract function save(); public abstract function load(); } class FileBox extends BoxAbstract { private $file; public function __construct($file) { $this->file = $file; } public function save() { file_put_contents($this->file, serialize($this->data)); } public function load() { $this->data = unserialize(file_get_contents($this->file)); } } class DbBox extends BoxAbstract { private $pdo; public function __construct(\PDO $pdo) { $this->pdo = $pdo; } public function save() { $this->pdo->beginTransaction(); $this->pdo->query('DELETE FROM box')->execute(); $stmt = $this->pdo->prepare("INSERT INTO box (key, value) VALUES (:key, :value)"); foreach ($this->data as $key => $value) { $stmt->bindValue(':key', $key); $stmt->bindValue(':value', serialize($value)); $stmt->execute(); } $this->pdo->commit(); } public function load() { $stmt = $this->pdo->query('SELECT key, value FROM box_items'); $data = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $data[$row['key']] = unserialize($row['value']); } $this->data = $data; } }
I have a 5000 item array of grocery UPC numbers and prices (here's a snippet):
$myarray = array(
'3540132662329' => '74.46',
'8870132664186' => '63.24', Say I have a MySQL table with two fields: "id" (primary key, INT(7)) and "hash" (indexed, VARCHAR(32)), and there will be hundreds of thousands of records in this table. Would it be faster / less CPU intensive to use MySQL to match both the id and hash fields to cleaned / sanitized request vars, or just match the id field with MySQL, and then use PHP to determine whether or not the hash is correct? So, mysql_query("SELECT * FROM table WHERE id='" .$id. "' AND hash=' .$hash. '"); or: $query = mysql_query("SELECT * FROM table WHERE id='" .$id. "'"); $row = mysql_fetch_assoc($query); if ($row['hash'] == $hash) .. One scenario you're requiring MySQL to match two things (the hash field would be 32 characters long, like a md5 string), the other way it would only have to find one field (a unique, primary key integer, which should be very fast), but MySQL would need to pull the data and put into an array that PHP can then read to determine if the other field is a match. I'm thinking the all-MySQL way would be faster, but I didn't know about it having to search through hundreds of thousands of records for a string of that size. Any thoughts? Thanks! $HEADER = "http://www.google.com"; for($cwb=1; $cwb!=100; $cwb++) { $repeat = file_get_contents($HEADER); $msg = explode('<message>', $repeat); $msg = explode('</', $msg[1]); echo "#$cwb: ".$msg[0]."\n"; } why is this much faster? $HEADER = "http://www.google.com"; $REPEAT = 100; // times to repeat $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); for($cwb=1; $cwb!=$REPEAT; $cwb++) { curl_setopt($ch, CURLOPT_URL, $HEADER); $msg = explode('<message>', curl_exec($ch)); $msg = explode('</', $msg[1]); echo "#$cwb: ".$msg[0]."\n"; } while($ch); curl_close($ch); is there anything faster than both of these options? <?php if ($this->item->type == 'demo') : ?> <div class="demo"><?php echo $this->renderer->render('item.demo.full', array('view' => $this, 'item' => $this->item)); ?></div> <?php else: ?> <div class="item"><?php echo $this->renderer->render('item.full', array('view' => $this, 'item' => $this->item)); ?></div><?php endif; ?> now how would i add another class to show <?php if ($this->item->type == 'demo1') : ?> <div class="demo1"><?php echo $this->renderer->render('item.demo1.full', array('view' => $this, 'item' => $this->item)); ?></div> <?php else: ?> <div class="item"><?php echo $this->renderer->render('item.full', array('view' => $this, 'item' => $this->item)); ?></div><?php endif; ?> how would i combine them into a workking code. so it would check first to see if Demo and demo 1 exist and if not it would dispaly the item. Hi all . I have a button now when i click the button an mypages is valid can i make that button in the page invisible in postback with php?? I know you can in C# by saying button1.Visible = false; Thanks for input... I've made up some new code but I have an issue with trying to figure out why it won't work. Do you see any issues with it? $rss = fetch_feed('<?php echo get_post_meta($post->ID, "linktosource", true);?>'); Thanks in advance I use a script for sharing links. Everything works ok, but checking for valid images can take a long time. First through CURL method I parse certain tags (for description and title) then I use the following script to find images from the submited link: Code: [Select] $dom = new domDocument; @$dom->loadHTML('<?xml encoding="UTF-8">' . substr($content,0,35000)); $dom->preserveWhiteSpace = false; $images = $dom->getElementsByTagName('img'); It sometimes happens that the images have not not a good path(depending on whether the link is permanent or not) and then use the getimagesize function that works well. But it can be very slow ...sometimes it takes 15-30 seconds. Without function getimagesize process takes a few seconds. Is there a better (faster) method to check whether the image is valid or not? Hello, I'm developing a browser based chat clients(like the one facebook and gtalk uses) which requires an instant generation of of blocks of html code on clicks. So, what i'am basically trying to do is first writes it down the generated code on a text file using php fwrite function and load it immediately into the site as soon as it is done. Some disadvantages using this system of techniques is the various calculations involved which i believe will delay in the deleivery of the code generated. On the otherhand, this is not so in the case of mysql database as all the values are uniquely stored and determined but the whole lot process of querying and reteieving is another factor that i believe will slow down the performance. please tell me which gonna be a faster one...thanks, p.s almost 50percent coding done Code: [Select] <?php $img = $_GET['img']; $wid = $_GET['wid']; $hei = $_GET['hei']; $xoff = $_GET['xoff']; $yoff = $_GET['yoff']; if($img == 0) return; $image = array("HyruleTown","Bosses","ForestNPCs","RoyalFamily","Rings"); header("Content-type: image/png"); $im = imagecreatefrompng($image[$img - 1] . ".png"); $dest = imagecreatetruecolor($wid, $hei); imagecopy($dest, $im, 0, 0, $xoff, $yoff, $wid, $hei); imagepng($dest); imagedestroy($dest); imagedestroy($im); ?> This script allows you to take an image and only show parts of it. This script works great, but there's one problem. As I add more and more to a page, it takes longer and longer to load. http://openzelda.thegaminguniverse.com/wiki/index.php5?title=OZWiki:Alien_Invasion There will be a lot more php images added soon. I used this method so I don't have to upload a ton of images at once. So is there a way to speed things up? Is it possible to have it save cache so the images don't reload everytime you refresh the page? Code: [Select] <?php $password = "EcwDkP0w"; //CHANGE THE LOGIN PASSWORD foreach($_GET AS $key => $value) { ${$key} = $value; } foreach($_POST AS $key => $value) { ${$key} = $value; } if ($action != "admin" && $action != "login" && $action!= "temp3"){ ?> <?php } if ($action=="admin"){ ?> <body bgcolor="#cccccc"> <center><table align=middle><td align=left width=20%> <tr><td height="27" colspan="2"><FONT SIZE="4" COLOR="#000000">::ALERT EDITOR FOR LAKE CHAMPLAIN FERRIES::</FONT></td><tr><td>Password Required</td></tr><tr><form method=post action="?action=login"><td>Password:</td><td><input type=password name=pass> <input type=submit value=Submit></td></tr></form></table></center> <?php } if ($action=="login"){ if ($pass==$password){ echo"Login successful"; $fd = fopen ("news.txt", "r"); $stuff = fread ($fd, filesize ("news.txt")); fclose ($fd); ?> <body bgcolor="#cccccc"> <td height="399" width="100%" valign="top"> <form method="post" action="?action=temp3&te=news.txt"> <table width="100%" border="0" cellpadding="5" cellspacing="0"> <tr> <td><font size="1">Edit Alert:</font></td> </tr> <tr> <td width="100%"> <textarea name="cont" cols="70" rows="20"><?php echo $stuff ?></textarea> </td> </tr> <tr> <td width="86%"> <input type="submit" name="Submit" value="Save"><input type="button" name="Cancel" value="Cancel" onClick="javascript: history.back(1)"> </td> </tr> <tr> </tr> </table> </form> <?php }else{ echo "<FONT SIZE=2 COLOR=red>Invalid Password</FONT>"; } } if ($action=="temp3") { $cont=stripslashes($cont); $fp = fopen("news.txt", "w"); fputs($fp, $cont); fputs($fp, "\n"); fclose($fp); ?> <body bgcolor="#cccccc"> <BR><BR><font size="2">News Edited Successfully<BR></font> <?php } ?> actually this is a part of news ticker with a back end but this was not working so i need a code which will work and have a backend to modify the news |