user->get('id'); $query = "CREATE TEMPORARY TABLE `plant_temp` SELECT id, modx_user_id, plant_type, plant_stage, n_min, n_max, P_min, P_max, K_min, K_max, S_min, S_max, Ca_min, Ca_max, Mg_min, Mg_max, Na_min, Na_max, Cu_min, Cu_max, Zn_min, Zn_max, Mn_min, Mn_max, B_min, B_max, Fe_min, Fe_max, M_min, M_max, Co_min, Co_max, se_min, se_max, cl_min, cl_max, c_min, c_max FROM `plant_specifications` WHERE `modx_user_id` = '" . $user_id . "' AND `plant_type` = '" . $empid . "'; "; $query .= "ALTER TABLE `plant_temp` DROP `id`, DROP `modx_user_id`, DROP `plant_type` ; "; $query .= "SELECT * FROM `plant_temp`; "; $result = mysqli_multi_query($con, $query); if ($result) { do { // grab the result of the next query if (($result = mysqli_store_result($con)) === false && mysqli_error($con) != '') { echo "Query failed: " . mysqli_error($con); } } while (mysqli_more_results($con) && mysqli_next_result($con)); // while there are more results } else { echo "First query failed..." . mysqli_error($con); } //get results from database $all_property = array(); //declare an array for saving property //showing property echo '
'; //initialize table tag while ($property = mysqli_fetch_field($result)) { $header = str_replace("_"," ",$property->name); echo ''; //get field name for header array_push($all_property, $property->name); //save those to array } echo ''; //end tr tag //showing all data while ($row = mysqli_fetch_array($result)) { echo ""; foreach ($all_property as $item) { if ($row[$item] == "" ) { $this_value = "0.0" ; } else { if (is_numeric($row[$item]) ) { $this_value = number_format((float)$row[$item], 2, '.', ''); } else { $this_value = $row[$item]; } } echo ''; //get items using property value } echo ''; } echo "
' . $header . '
id] . '","' . $row['id'] . '")" onClick="showEdit(this);" >' . $this_value . '
"; echo "
"; $img_query = 'SELECT * FROM `plant_images` ORDER BY `id` DESC'; $img_result = mysqli_query($con, $img_query); while($img_row = mysqli_fetch_array($img_result)) { echo ' '; } echo "

"; $query .= "DROP TEMPORARY TABLE `temp`; "; mysqli_query($con, $query); mysqli_close($con); ?>