PHP - How Can I Make This Code Only Load The First 30 Rows Or Run Faster On Loading?
When 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=""; } Similar TutorialsI 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 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? $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 />';} I am building a commenting system, it's sort of like facebooks comments. I have it right now so it loads the first last 3 comments in the database, and then there's a button to view all comments. I have it working fine, except when you add another comment to it, and then click the view all comments, This is the script that loads onload showing the last 3 comments $limit = 3; $query5 = mysql_query("SELECT * FROM sub_comments WHERE status_id='$id' ORDER BY id DESC LIMIT $limit"); This is the php script that runs when you click view more //($start_id would be 3 in this case) $query5 = mysql_query("SELECT * FROM sub_comments WHERE status_id='$comment_id' ORDER BY id DESC LIMIT $start_id, 1000"); so to try to show you what's happening: OnLoad--------------------------------|---When you add more comments, (let's just say u add 1 comment before u click view comments)---- comment 9 --------------------------| comment 10 comment 8 --------------------------| comment 9 comment 7 --------------------------| comment 8 ------------------------------------------| comment 7 ----to be loaded onclick-------------|------What's loaded onclick--- comment 6 --------------------------| comment 7 comment 5 --------------------------| comment 6 comment 4 --------------------------| comment 5 comment 3 --------------------------| comment 4 comment 2 --------------------------| comment 3 comment 1 --------------------------| comment 2 ------------------------------------------| comment 1 (see how "comment 7" is being shown twice in a row) <?xml-stylesheet href="/player.xsl" type="text/xsl"?> <config> <auto_start>false</auto_start> <player_skin>/test.swf</player_skin> <main_title>Test</main_title> <playlist_title>PLAYLIST</playlist_title> <time_text>TOTAL TIME</time_text> <pan_labels>L,R</pan_labels> <scroller_speed>1</scroller_speed> <scroller_marquee_content>#TRACK_NAME#</scroller_marquee_content> <repeat_is_enabled>false</repeat_is_enabled> <shuffle_is_enabled>false</shuffle_is_enabled> <default_volume>75</default_volume> <default_pan>0</default_pan> <play_list> <item>test.mp3;Test Soundtrack</item> </play_list> </config>Hi, The above code is from an XML file and I added the <?xml line of code to the XML file, but doing so causes the whole page to no longer display the track information (just blank). Is there there a way I could modify that text to try and call it another way? Thanks Edited by hexcode, 16 July 2014 - 02:52 PM. The following works, but I don't want to have to write 50 query statements for 50 states. How can I just write one query (using a variable I presume) and then echo the variable count each time for each state? I'm just trying to list the total number of rows for each state, that exist in the db. <? $result = mysql_query("SELECT * FROM mytable WHERE source = 'alabama'") or die(mysql_error()); $num_rows = mysql_num_rows($result); ?> href="/state/alabama/">alabama</a> (<?php echo("$num_rows");?>) <br> <? $result = mysql_query("SELECT * FROM mytable WHERE source = 'alaska'") or die(mysql_error()); $num_rows = mysql_num_rows($result); ?> href="/state/alaska/">alaska</a> (<?php echo("$num_rows");?>) <br> The above would give output such as: alabama (122) alaska (212) Hi,
what I'm tryng is to append a table row with associated jquery code...
I have a jquery code just like this
<script type="text/javascript"> jQuery(function($) { var rowCtr = 0; $('.addRow').click(function(){ $('#tableID > tbody:last').append('<tr name="rowEq['+rowCtr+']" id="rowEq['+rowCtr+']"><td>'+ '<select id="stype'+rowCtr+'" name="rowData['+rowCtr+'][equipment_type]">'+ '<option value="0"> -- </option>'+ '<option value="1"> Type 1 </option>'+ '<option value="2"> Type 2 </option>'+ '<option value="3"> Other </option>'+ '</select>'+ '<input id="other_type'+rowCtr+'" type="text" name="rowData['+rowCtr+'][other_type]">'+ ); $('#stype'+rowCtr).change(function() { if(jQuery('#stype'+rowCtr).val() == '3') { jQuery('#other_type'+rowCtr).show(); }else{ jQuery('#other_type'+rowCtr).hide(); } }); if(jQuery( '#stype'+rowCtr ).val() != '3') { jQuery('#other_type'+rowCtr).hide(); } rowCtr++; }); }); </script>And html like this.. <input type='button' class='addRow' value="Add Row"> <form> <table id="tableId"> <thead> <tr> <th> Type </th> </tr> </thead> <tbody> <tr> <td> dummy text.. </td> </tr> </tbody> </table> </form>The appending is ok but the hidding/showing of "other_type" field is not working. It always hide "other_type" field even if I already selected the 'other' option. tbl1.png 3.38KB 0 downloads 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 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"; } } } ?> 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? 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', $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? 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! <?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. what Im basically trying to do is just like a phpmyadmin function... you select rows you want to update with a checkbox and then it takes you to a page where the rows that are clicked are shown in forms so that you can view and edit info in them... and then have 1 submit button to update them all at once. |