php/mysql table

  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

OK ... so i think i have an idea of whats going on and how to go about fixing it again i'm not by my computer and these posts are being sent with my phone but i believe the issue lies in the building of the table array the content is being over written the variable $ii i used previously is removed from this code. but what does confusing me is your saying once you add more content to the db it goes back to the side by side? is that correct?
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

no.
it just does not show up.
Image
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Ok that confirms my theory when I get to my computer I'll put the counts in the code
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

PHP Code: [ Select ]
<?php
 
// Initialize
require_once('data.php');
 
 
// These are functions to help make the code nicer and easier to read and by all means not required
// This function is just to make code pretty and returns tabs '\t'. This function relies on the repeat_string function
function tab($number = 1)
{
    // Call repeat_string and return the tabs
    return repeat_string("\t", $number);
}
 
// This function is just to make code pretty and returns hard spaces '\r\n'. This function relies on the repeat_string function
function hs($number = 1)
{
    // Call repeat_string and return the tabs
    return repeat_string("\r\n", $number);
}
 
// This function will build a string with a certain number of repeats. Example \r\n\r\n
function repeat_string($type, $number = 1)
{
   
    // Make a return var
    $return = array();
 
    // Loop the number
    for($i=0; $i < $number; $i++)
    {
        // Add the tab
        $return[] = $type;
    }
 
    // Return the hard space
    return implode('', $return);
   
}
 
// This function is a pretty vardump
function pd($input)
{
    echo '<pre>'; var_dump($input); echo '</pre>';  
}
// The functions above are to help make the code nicer and easier to read and by all means not required.
 
 
 
// This function will build out the inner table for all cases
function build_table($row, $type, $temp)
{
    // Create an array to hold the table
    $return = array();
   
    // Setup the surrounding div tag to properly color the table
    switch($type)
    {
        case 'STEEL':
            $return[] = tab(5) .'<div style="background-color:#FF9999;">';
            break;
        case 'SLIM':
            $return[] = tab(5) .'<div style="background-color:#9999FF;">';
            break;
        case 'KYMERA':
            $return[] = tab(5) .'<div style="background-color:#FF2626;">';
            break;
        case 'HYBRID':
            $return[] = tab(5) .'<div style="background-color:#FF2626;">';
            break;
        case 'EZC':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        case 'RWD':
            $return[] = tab(5) .'<div style="background-color:#FF9326;">';
            break;
        case 'EZR':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        case 'EZB':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        default:
            $return[] = tab(5) .'<div>';
    }
   
    // Start building the output
    $return[] = tab(6) .'<a href="operator.php?id='. $row['serial'] .'">';
    $return[] = tab(7) .'<div style="border:solid; border-color:#000000;">';
    $return[] = tab(8) .'<table border="0" cellspacing="0" cellpadding="0" width="100%">';
   
   // Take their temperature and add to the output if their temperature matches
    switch($temp)
    {
        case 'ultrahot':
            $return[] = tab(9) .'<tr>';
            $return[] = tab(10) .'<td>';
            $return[] = tab(11) .'<div style="background-color:#FF0000;">*Ultra Hot*</div>';
            $return[] = tab(10) .'</td>';
            $return[] = tab(9) .'</tr>';
            break;
 
        case 'hot':
            $return[] = tab(9) .'<tr>';
            $return[] = tab(10) .'<td>';
            $return[] = tab(11) .'<div style="background-color:#FF0000;">*HOT*</div>';
            $return[] = tab(10) .'</td>';
            $return[] = tab(9) .'</tr>';
            break;
    }
   
    // Finish building the output
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='. $row['serial'].'">'. $row['serial'] .'</a>&nbsp;<a href="operator.php?id='.$row['serial'].'">'. $row['load_wk'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['crown'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['size'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
   
        $return[] = tab(8) .'</table>';
        $return[] = tab(7) .'</div>';
        $return[] = tab(6) .'</a>';
        $return[] = tab(5) .'</div>';
 
    // Join and return the output
    return implode(hs(), $return);
}
 
// This function will build and return the table row
function build_row($keys, $rows, $type)
{
   
    // Add return array we must.
    $return = array();
 
    // What type it is do we know. Hmmmm, yes.
    switch($type)
    {
        case '1':
            $text = 'In Machine';
            break;
        case '0':
            $text = 'Machine Que';
            break;
    }
   
    // Loop through the table keys to build the columns
    foreach($keys as $value)
    {
        // Start the output
        $return[] = tab(3) . '<td align="center">';
        $return[] = tab(4) . $text;
        $return[] = tab(4) . '<div style="overflow:auto; height:200px; width:110px;">';
       
        // Make sure we have an array
        if(isset($rows[$value]))
        {
            // Loop through the values that are in the on machine row of the table
            foreach($rows[$value] as $key => $table_row)
            {
                // Check for NULL
                if(isset($table_row[$type]['status']))
                {
                    // Build the ultra hot table
                    if($table_row[$type]['status']['ultrahot'])
                    {
                        $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'ultrahot');
                    }
                   
                    // Build the hot table
                    if($table_row[$type]['status']['hot'])
                    {
                        $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'hot');
                    }
 
                    // Build the normal table
                    if($table_row[$type]['status']['status'])
                    {
                        $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
                    }
                }
            }
        }
 
        $return[] = tab(4) . '</div>';
        $return[] = tab(3) . '</td>';
 
    }
   
    // Join and return the output
    return implode(hs(), $return);
}
         
// Set SQL Query
$query = "SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.status";
 
// Execute
$results_key = mysql_query($query) or die(mysql_error());
 
// Make the arrays to hold the table info
$table      = array();
$table_keys = array();
 
// Loop the results
while($row = mysql_fetch_assoc($results_key))
{
   
    // Set the table header
    $table_keys[] = $row['machine'];
 
    // Check to see if this bit is on the machine.
    $on_machine = ($row['onmachine']) ? '1' : '0';
 
    // Sort by temperature starting with ultrahot
    if($row['ultrahot'])
    {
        $table[$row['machine']][][$on_machine]['ultrahot'] = $row;
    }
    elseif($row['hot'])
    {
        $table[$row['machine']][][$on_machine]['hot'] = $row;
    }
    else
    {
        $table[$row['machine']][][$on_machine]['status'] = $row;
    }
   
    $table_keys = array_unique($table_keys);
   
}
 //print_r($table);
?>
 
<div style="overflow:auto; width:100%; height:100%">
    <table border="1" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
        <tr>
            <td align="center"><?php echo implode('</td><td>', $table_keys); ?></td>
        </tr>
        <tr>
            <?php echo build_row($table_keys, $table, '1'); ?>
        </tr>
        <tr>
            <?php echo build_row($table_keys, $table, '0'); ?>
        </tr>
    </table>
</div>
 
  1. <?php
  2.  
  3. // Initialize
  4. require_once('data.php');
  5.  
  6.  
  7. // These are functions to help make the code nicer and easier to read and by all means not required
  8. // This function is just to make code pretty and returns tabs '\t'. This function relies on the repeat_string function
  9. function tab($number = 1)
  10. {
  11.     // Call repeat_string and return the tabs
  12.     return repeat_string("\t", $number);
  13. }
  14.  
  15. // This function is just to make code pretty and returns hard spaces '\r\n'. This function relies on the repeat_string function
  16. function hs($number = 1)
  17. {
  18.     // Call repeat_string and return the tabs
  19.     return repeat_string("\r\n", $number);
  20. }
  21.  
  22. // This function will build a string with a certain number of repeats. Example \r\n\r\n
  23. function repeat_string($type, $number = 1)
  24. {
  25.    
  26.     // Make a return var
  27.     $return = array();
  28.  
  29.     // Loop the number
  30.     for($i=0; $i < $number; $i++)
  31.     {
  32.         // Add the tab
  33.         $return[] = $type;
  34.     }
  35.  
  36.     // Return the hard space
  37.     return implode('', $return);
  38.    
  39. }
  40.  
  41. // This function is a pretty vardump
  42. function pd($input)
  43. {
  44.     echo '<pre>'; var_dump($input); echo '</pre>';  
  45. }
  46. // The functions above are to help make the code nicer and easier to read and by all means not required.
  47.  
  48.  
  49.  
  50. // This function will build out the inner table for all cases
  51. function build_table($row, $type, $temp)
  52. {
  53.     // Create an array to hold the table
  54.     $return = array();
  55.    
  56.     // Setup the surrounding div tag to properly color the table
  57.     switch($type)
  58.     {
  59.         case 'STEEL':
  60.             $return[] = tab(5) .'<div style="background-color:#FF9999;">';
  61.             break;
  62.         case 'SLIM':
  63.             $return[] = tab(5) .'<div style="background-color:#9999FF;">';
  64.             break;
  65.         case 'KYMERA':
  66.             $return[] = tab(5) .'<div style="background-color:#FF2626;">';
  67.             break;
  68.         case 'HYBRID':
  69.             $return[] = tab(5) .'<div style="background-color:#FF2626;">';
  70.             break;
  71.         case 'EZC':
  72.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  73.             break;
  74.         case 'RWD':
  75.             $return[] = tab(5) .'<div style="background-color:#FF9326;">';
  76.             break;
  77.         case 'EZR':
  78.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  79.             break;
  80.         case 'EZB':
  81.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  82.             break;
  83.         default:
  84.             $return[] = tab(5) .'<div>';
  85.     }
  86.    
  87.     // Start building the output
  88.     $return[] = tab(6) .'<a href="operator.php?id='. $row['serial'] .'">';
  89.     $return[] = tab(7) .'<div style="border:solid; border-color:#000000;">';
  90.     $return[] = tab(8) .'<table border="0" cellspacing="0" cellpadding="0" width="100%">';
  91.    
  92.    // Take their temperature and add to the output if their temperature matches
  93.     switch($temp)
  94.     {
  95.         case 'ultrahot':
  96.             $return[] = tab(9) .'<tr>';
  97.             $return[] = tab(10) .'<td>';
  98.             $return[] = tab(11) .'<div style="background-color:#FF0000;">*Ultra Hot*</div>';
  99.             $return[] = tab(10) .'</td>';
  100.             $return[] = tab(9) .'</tr>';
  101.             break;
  102.  
  103.         case 'hot':
  104.             $return[] = tab(9) .'<tr>';
  105.             $return[] = tab(10) .'<td>';
  106.             $return[] = tab(11) .'<div style="background-color:#FF0000;">*HOT*</div>';
  107.             $return[] = tab(10) .'</td>';
  108.             $return[] = tab(9) .'</tr>';
  109.             break;
  110.     }
  111.    
  112.     // Finish building the output
  113.     $return[] = tab(9) .'<tr>';
  114.     $return[] = tab(10) .'<td><a href="operator.php?id='. $row['serial'].'">'. $row['serial'] .'</a>&nbsp;<a href="operator.php?id='.$row['serial'].'">'. $row['load_wk'] .'</a></td>';
  115.     $return[] = tab(9) .'</tr>';
  116.     $return[] = tab(9) .'<tr>';
  117.     $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['crown'] .'</a></td>';
  118.     $return[] = tab(9) .'</tr>';
  119.     $return[] = tab(9) .'<tr>';
  120.     $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['size'] .'</a></td>';
  121.     $return[] = tab(9) .'</tr>';
  122.    
  123.         $return[] = tab(8) .'</table>';
  124.         $return[] = tab(7) .'</div>';
  125.         $return[] = tab(6) .'</a>';
  126.         $return[] = tab(5) .'</div>';
  127.  
  128.     // Join and return the output
  129.     return implode(hs(), $return);
  130. }
  131.  
  132. // This function will build and return the table row
  133. function build_row($keys, $rows, $type)
  134. {
  135.    
  136.     // Add return array we must.
  137.     $return = array();
  138.  
  139.     // What type it is do we know. Hmmmm, yes.
  140.     switch($type)
  141.     {
  142.         case '1':
  143.             $text = 'In Machine';
  144.             break;
  145.         case '0':
  146.             $text = 'Machine Que';
  147.             break;
  148.     }
  149.    
  150.     // Loop through the table keys to build the columns
  151.     foreach($keys as $value)
  152.     {
  153.         // Start the output
  154.         $return[] = tab(3) . '<td align="center">';
  155.         $return[] = tab(4) . $text;
  156.         $return[] = tab(4) . '<div style="overflow:auto; height:200px; width:110px;">';
  157.        
  158.         // Make sure we have an array
  159.         if(isset($rows[$value]))
  160.         {
  161.             // Loop through the values that are in the on machine row of the table
  162.             foreach($rows[$value] as $key => $table_row)
  163.             {
  164.                 // Check for NULL
  165.                 if(isset($table_row[$type]['status']))
  166.                 {
  167.                     // Build the ultra hot table
  168.                     if($table_row[$type]['status']['ultrahot'])
  169.                     {
  170.                         $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'ultrahot');
  171.                     }
  172.                    
  173.                     // Build the hot table
  174.                     if($table_row[$type]['status']['hot'])
  175.                     {
  176.                         $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'hot');
  177.                     }
  178.  
  179.                     // Build the normal table
  180.                     if($table_row[$type]['status']['status'])
  181.                     {
  182.                         $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
  183.                     }
  184.                 }
  185.             }
  186.         }
  187.  
  188.         $return[] = tab(4) . '</div>';
  189.         $return[] = tab(3) . '</td>';
  190.  
  191.     }
  192.    
  193.     // Join and return the output
  194.     return implode(hs(), $return);
  195. }
  196.          
  197. // Set SQL Query
  198. $query = "SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.status";
  199.  
  200. // Execute
  201. $results_key = mysql_query($query) or die(mysql_error());
  202.  
  203. // Make the arrays to hold the table info
  204. $table      = array();
  205. $table_keys = array();
  206.  
  207. // Loop the results
  208. while($row = mysql_fetch_assoc($results_key))
  209. {
  210.    
  211.     // Set the table header
  212.     $table_keys[] = $row['machine'];
  213.  
  214.     // Check to see if this bit is on the machine.
  215.     $on_machine = ($row['onmachine']) ? '1' : '0';
  216.  
  217.     // Sort by temperature starting with ultrahot
  218.     if($row['ultrahot'])
  219.     {
  220.         $table[$row['machine']][][$on_machine]['ultrahot'] = $row;
  221.     }
  222.     elseif($row['hot'])
  223.     {
  224.         $table[$row['machine']][][$on_machine]['hot'] = $row;
  225.     }
  226.     else
  227.     {
  228.         $table[$row['machine']][][$on_machine]['status'] = $row;
  229.     }
  230.    
  231.     $table_keys = array_unique($table_keys);
  232.    
  233. }
  234.  //print_r($table);
  235. ?>
  236.  
  237. <div style="overflow:auto; width:100%; height:100%">
  238.     <table border="1" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
  239.         <tr>
  240.             <td align="center"><?php echo implode('</td><td>', $table_keys); ?></td>
  241.         </tr>
  242.         <tr>
  243.             <?php echo build_row($table_keys, $table, '1'); ?>
  244.         </tr>
  245.         <tr>
  246.             <?php echo build_row($table_keys, $table, '0'); ?>
  247.         </tr>
  248.     </table>
  249. </div>
  250.  
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

That does save from using a counter which I was leaning for. I'd still move the array_unique out of the while so it only fires once. On a side note you could have made use of my pretty dump function pd($table); instead of print_r($table); :wink:
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

I actually have an error there in the suggested fix (where ultrahot and hot won't work). I fixed it in here.

Thanks ScottG. I originally had it outside of the loop, but after 30+ minutes of editing, re-editing the code, I must have moved it in the loop. I don't like how dumps look. Print_rs just displays the keys and values (I view source to see it neat). Var_dumps also tells me the data-type... makes it a bit ugly and crowded for my liking. I guess I could've modified pd($table) to use print_r() instead of var_dump();

Those are nice set of tidy-ing up functions you got there. I might reuse them myself in my own projects :D (if I may :lol: )

PHP Code: [ Select ]
<?php
 
// Initialize
require_once('data.php');
 
 
// These are functions to help make the code nicer and easier to read and by all means not required
// This function is just to make code pretty and returns tabs '\t'. This function relies on the repeat_string function
function tab($number = 1)
{
    // Call repeat_string and return the tabs
    return repeat_string("\t", $number);
}
 
// This function is just to make code pretty and returns hard spaces '\r\n'. This function relies on the repeat_string function
function hs($number = 1)
{
    // Call repeat_string and return the tabs
    return repeat_string("\r\n", $number);
}
 
// This function will build a string with a certain number of repeats. Example \r\n\r\n
function repeat_string($type, $number = 1)
{
   
    // Make a return var
    $return = array();
 
    // Loop the number
    for($i=0; $i < $number; $i++)
    {
        // Add the tab
        $return[] = $type;
    }
 
    // Return the hard space
    return implode('', $return);
   
}
 
// This function is a pretty vardump
function pd($input)
{
    echo '<pre>'; var_dump($input); echo '</pre>';  
}
// The functions above are to help make the code nicer and easier to read and by all means not required.
 
 
 
// This function will build out the inner table for all cases
function build_table($row, $type, $temp)
{
    if(empty($row['id']))
    {
        return;
    }
 
    // Create an array to hold the table
    $return = array();
   
    // Setup the surrounding div tag to properly color the table
    switch($type)
    {
        case 'STEEL':
            $return[] = tab(5) .'<div style="background-color:#FF9999;">';
            break;
        case 'SLIM':
            $return[] = tab(5) .'<div style="background-color:#9999FF;">';
            break;
        case 'KYMERA':
            $return[] = tab(5) .'<div style="background-color:#FF2626;">';
            break;
        case 'HYBRID':
            $return[] = tab(5) .'<div style="background-color:#FF2626;">';
            break;
        case 'EZC':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        case 'RWD':
            $return[] = tab(5) .'<div style="background-color:#FF9326;">';
            break;
        case 'EZR':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        case 'EZB':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        default:
            $return[] = tab(5) .'<div>';
    }
   
    // Start building the output
    $return[] = tab(6) .'<a href="operator.php?id='. $row['serial'] .'">';
    $return[] = tab(7) .'<div style="border:solid; border-color:#000000;">';
    $return[] = tab(8) .'<table border="0" cellspacing="0" cellpadding="0" width="100%">';
   
   // Take their temperature and add to the output if their temperature matches
    switch($temp)
    {
        case 'ultrahot':
            $return[] = tab(9) .'<tr>';
            $return[] = tab(10) .'<td>';
            $return[] = tab(11) .'<div style="background-color:#FF0000;">*Ultra Hot*</div>';
            $return[] = tab(10) .'</td>';
            $return[] = tab(9) .'</tr>';
            break;
 
        case 'hot':
            $return[] = tab(9) .'<tr>';
            $return[] = tab(10) .'<td>';
            $return[] = tab(11) .'<div style="background-color:#FF0000;">*HOT*</div>';
            $return[] = tab(10) .'</td>';
            $return[] = tab(9) .'</tr>';
            break;
    }
   
    // Finish building the output
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='. $row['serial'].'">'. $row['serial'] .'</a>&nbsp;<a href="operator.php?id='.$row['serial'].'">'. $row['load_wk'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['crown'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['size'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
    $return[] = tab(8) .'</table>';
    $return[] = tab(7) .'</div>';
    $return[] = tab(6) .'</a>';
    $return[] = tab(5) .'</div>';
 
    // Join and return the output
    return implode(hs(), $return);
}
 
// This function will build and return the table row
function build_row($keys, $rows, $type)
{
   
    // Add return array we must.
    $return = array();
 
    // What type it is do we know. Hmmmm, yes.
    switch($type)
    {
        case '1':
            $text = 'In Machine';
            break;
        case '0':
            $text = 'Machine Que';
            break;
    }
   
    // Loop through the table keys to build the columns
    foreach($keys as $value)
    {
        // Start the output
        $return[] = tab(3) . '<td align="center">';
        $return[] = tab(4) . $text;
        $return[] = tab(4) . '<div style="overflow:auto; height:200px; width:110px;">';
       
        // Make sure we have an array
        if(isset($rows[$value]))
        {
            // Loop through the values that are in the on machine row of the table
            foreach($rows[$value] as $key => $table_row)
            {
                // Check for NULL
                if(isset($table_row[$type]))
                {
                    // Build the ultra hot table
                    if(isset($table_row[$type]['ultrahot']))
                    {
                        $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
                    }
                   
                    // Build the hot table
                    if(isset($table_row[$type]['hot']))
                    {
                        $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
                    }
 
                    // Build the normal table
                    if(isset($table_row[$type]['status']))
                    {
                        $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
                    }
                }
            }
        }
 
        $return[] = tab(4) . '</div>';
        $return[] = tab(3) . '</td>';
 
    }
   
    // Join and return the output
    return implode(hs(), $return);
}
         
// Set SQL Query
$query = "SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.status";
 
// Execute
$results_key = mysql_query($query) or die(mysql_error());
 
// Make the arrays to hold the table info
$table      = array();
$table_keys = array();
 
// Loop the results
while($row = mysql_fetch_assoc($results_key))
{
   
    // Set the table header
    $table_keys[] = $row['machine'];
 
    // Check to see if this bit is on the machine.
    $on_machine = ($row['onmachine']) ? '1' : '0';
 
    // Sort by temperature starting with ultrahot
    if($row['ultrahot'])
    {
        $table[$row['machine']][][$on_machine]['ultrahot'] = $row;
    }
    elseif($row['hot'])
    {
        $table[$row['machine']][][$on_machine]['hot'] = $row;
    }
    else
    {
        $table[$row['machine']][][$on_machine]['status'] = $row;
    }
}
 
$table_keys = array_unique($table_keys);
 
?>
 
<div style="overflow:auto; width:100%; height:100%">
    <table border="1" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
        <tr>
            <td align="center"><?php echo implode('</td><td>', $table_keys); ?></td>
        </tr>
        <tr>
            <?php echo build_row($table_keys, $table, '1'); ?>
        </tr>
        <tr>
            <?php echo build_row($table_keys, $table, '0'); ?>
        </tr>
    </table>
</div>
 
  1. <?php
  2.  
  3. // Initialize
  4. require_once('data.php');
  5.  
  6.  
  7. // These are functions to help make the code nicer and easier to read and by all means not required
  8. // This function is just to make code pretty and returns tabs '\t'. This function relies on the repeat_string function
  9. function tab($number = 1)
  10. {
  11.     // Call repeat_string and return the tabs
  12.     return repeat_string("\t", $number);
  13. }
  14.  
  15. // This function is just to make code pretty and returns hard spaces '\r\n'. This function relies on the repeat_string function
  16. function hs($number = 1)
  17. {
  18.     // Call repeat_string and return the tabs
  19.     return repeat_string("\r\n", $number);
  20. }
  21.  
  22. // This function will build a string with a certain number of repeats. Example \r\n\r\n
  23. function repeat_string($type, $number = 1)
  24. {
  25.    
  26.     // Make a return var
  27.     $return = array();
  28.  
  29.     // Loop the number
  30.     for($i=0; $i < $number; $i++)
  31.     {
  32.         // Add the tab
  33.         $return[] = $type;
  34.     }
  35.  
  36.     // Return the hard space
  37.     return implode('', $return);
  38.    
  39. }
  40.  
  41. // This function is a pretty vardump
  42. function pd($input)
  43. {
  44.     echo '<pre>'; var_dump($input); echo '</pre>';  
  45. }
  46. // The functions above are to help make the code nicer and easier to read and by all means not required.
  47.  
  48.  
  49.  
  50. // This function will build out the inner table for all cases
  51. function build_table($row, $type, $temp)
  52. {
  53.     if(empty($row['id']))
  54.     {
  55.         return;
  56.     }
  57.  
  58.     // Create an array to hold the table
  59.     $return = array();
  60.    
  61.     // Setup the surrounding div tag to properly color the table
  62.     switch($type)
  63.     {
  64.         case 'STEEL':
  65.             $return[] = tab(5) .'<div style="background-color:#FF9999;">';
  66.             break;
  67.         case 'SLIM':
  68.             $return[] = tab(5) .'<div style="background-color:#9999FF;">';
  69.             break;
  70.         case 'KYMERA':
  71.             $return[] = tab(5) .'<div style="background-color:#FF2626;">';
  72.             break;
  73.         case 'HYBRID':
  74.             $return[] = tab(5) .'<div style="background-color:#FF2626;">';
  75.             break;
  76.         case 'EZC':
  77.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  78.             break;
  79.         case 'RWD':
  80.             $return[] = tab(5) .'<div style="background-color:#FF9326;">';
  81.             break;
  82.         case 'EZR':
  83.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  84.             break;
  85.         case 'EZB':
  86.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  87.             break;
  88.         default:
  89.             $return[] = tab(5) .'<div>';
  90.     }
  91.    
  92.     // Start building the output
  93.     $return[] = tab(6) .'<a href="operator.php?id='. $row['serial'] .'">';
  94.     $return[] = tab(7) .'<div style="border:solid; border-color:#000000;">';
  95.     $return[] = tab(8) .'<table border="0" cellspacing="0" cellpadding="0" width="100%">';
  96.    
  97.    // Take their temperature and add to the output if their temperature matches
  98.     switch($temp)
  99.     {
  100.         case 'ultrahot':
  101.             $return[] = tab(9) .'<tr>';
  102.             $return[] = tab(10) .'<td>';
  103.             $return[] = tab(11) .'<div style="background-color:#FF0000;">*Ultra Hot*</div>';
  104.             $return[] = tab(10) .'</td>';
  105.             $return[] = tab(9) .'</tr>';
  106.             break;
  107.  
  108.         case 'hot':
  109.             $return[] = tab(9) .'<tr>';
  110.             $return[] = tab(10) .'<td>';
  111.             $return[] = tab(11) .'<div style="background-color:#FF0000;">*HOT*</div>';
  112.             $return[] = tab(10) .'</td>';
  113.             $return[] = tab(9) .'</tr>';
  114.             break;
  115.     }
  116.    
  117.     // Finish building the output
  118.     $return[] = tab(9) .'<tr>';
  119.     $return[] = tab(10) .'<td><a href="operator.php?id='. $row['serial'].'">'. $row['serial'] .'</a>&nbsp;<a href="operator.php?id='.$row['serial'].'">'. $row['load_wk'] .'</a></td>';
  120.     $return[] = tab(9) .'</tr>';
  121.     $return[] = tab(9) .'<tr>';
  122.     $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['crown'] .'</a></td>';
  123.     $return[] = tab(9) .'</tr>';
  124.     $return[] = tab(9) .'<tr>';
  125.     $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['size'] .'</a></td>';
  126.     $return[] = tab(9) .'</tr>';
  127.     $return[] = tab(8) .'</table>';
  128.     $return[] = tab(7) .'</div>';
  129.     $return[] = tab(6) .'</a>';
  130.     $return[] = tab(5) .'</div>';
  131.  
  132.     // Join and return the output
  133.     return implode(hs(), $return);
  134. }
  135.  
  136. // This function will build and return the table row
  137. function build_row($keys, $rows, $type)
  138. {
  139.    
  140.     // Add return array we must.
  141.     $return = array();
  142.  
  143.     // What type it is do we know. Hmmmm, yes.
  144.     switch($type)
  145.     {
  146.         case '1':
  147.             $text = 'In Machine';
  148.             break;
  149.         case '0':
  150.             $text = 'Machine Que';
  151.             break;
  152.     }
  153.    
  154.     // Loop through the table keys to build the columns
  155.     foreach($keys as $value)
  156.     {
  157.         // Start the output
  158.         $return[] = tab(3) . '<td align="center">';
  159.         $return[] = tab(4) . $text;
  160.         $return[] = tab(4) . '<div style="overflow:auto; height:200px; width:110px;">';
  161.        
  162.         // Make sure we have an array
  163.         if(isset($rows[$value]))
  164.         {
  165.             // Loop through the values that are in the on machine row of the table
  166.             foreach($rows[$value] as $key => $table_row)
  167.             {
  168.                 // Check for NULL
  169.                 if(isset($table_row[$type]))
  170.                 {
  171.                     // Build the ultra hot table
  172.                     if(isset($table_row[$type]['ultrahot']))
  173.                     {
  174.                         $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
  175.                     }
  176.                    
  177.                     // Build the hot table
  178.                     if(isset($table_row[$type]['hot']))
  179.                     {
  180.                         $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
  181.                     }
  182.  
  183.                     // Build the normal table
  184.                     if(isset($table_row[$type]['status']))
  185.                     {
  186.                         $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
  187.                     }
  188.                 }
  189.             }
  190.         }
  191.  
  192.         $return[] = tab(4) . '</div>';
  193.         $return[] = tab(3) . '</td>';
  194.  
  195.     }
  196.    
  197.     // Join and return the output
  198.     return implode(hs(), $return);
  199. }
  200.          
  201. // Set SQL Query
  202. $query = "SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.status";
  203.  
  204. // Execute
  205. $results_key = mysql_query($query) or die(mysql_error());
  206.  
  207. // Make the arrays to hold the table info
  208. $table      = array();
  209. $table_keys = array();
  210.  
  211. // Loop the results
  212. while($row = mysql_fetch_assoc($results_key))
  213. {
  214.    
  215.     // Set the table header
  216.     $table_keys[] = $row['machine'];
  217.  
  218.     // Check to see if this bit is on the machine.
  219.     $on_machine = ($row['onmachine']) ? '1' : '0';
  220.  
  221.     // Sort by temperature starting with ultrahot
  222.     if($row['ultrahot'])
  223.     {
  224.         $table[$row['machine']][][$on_machine]['ultrahot'] = $row;
  225.     }
  226.     elseif($row['hot'])
  227.     {
  228.         $table[$row['machine']][][$on_machine]['hot'] = $row;
  229.     }
  230.     else
  231.     {
  232.         $table[$row['machine']][][$on_machine]['status'] = $row;
  233.     }
  234. }
  235.  
  236. $table_keys = array_unique($table_keys);
  237.  
  238. ?>
  239.  
  240. <div style="overflow:auto; width:100%; height:100%">
  241.     <table border="1" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
  242.         <tr>
  243.             <td align="center"><?php echo implode('</td><td>', $table_keys); ?></td>
  244.         </tr>
  245.         <tr>
  246.             <?php echo build_row($table_keys, $table, '1'); ?>
  247.         </tr>
  248.         <tr>
  249.             <?php echo build_row($table_keys, $table, '0'); ?>
  250.         </tr>
  251.     </table>
  252. </div>
  253.  


Here though, for some reason there are empty click-able squares in the Machine Que if there is nothing in the InMachine or the Machine Que.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

I also want to bring your attention to a problem. There is no way to order ultrahot, then hot and then regular since it's coming out of the database in no particular order. You could add 'ORDER BY bits.ultrahot DESC' to the query and then it's guaranteed that at least ultrahot would display first. But this way, you just can't order them like you want without drastically changing the current code as it is (I think).

Also, if you change the SQL from LEFT JOIN to JOIN, you would hide all the empty machines. The machines would appear once there's something to display there. Just makes the entire thing look better in my opinion.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

I use to use print_r() all the time but when the array becomes a string by accident or design i hated seeing the error I too dont like all of the info in th var dump but it runs everything I do however have a similar function called pr() which does just what your modification suggests but i like to say pd lol feel free to use them I've posted variations of those functions on here before.

As for the empty clickable boxes in the function build table at the top add a check to see if there is any info in the $row

something like
PHP Code: [ Select ]
if(empty($row)){
 return;
}
 
  1. if(empty($row)){
  2.  return;
  3. }
  4.  
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

I need all the machines to show as it is part of a future expansion of the project.

now the ultra hot/hot/regular it needs to be like that because ultrahot bits need to go on first and what ever is up top will go on next to the machine.

so ultrahot bits are hotter than hot bits
hot bits are hotter than regular bits

all need to be ordered by there bitdate unless ultrahot/hot status
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

PHP Code: [ Select ]
if(empty($row['id']))
{
    return;
}
  1. if(empty($row['id']))
  2. {
  3.     return;
  4. }
Did the trick.

I knew I needed that, but I didn't think that that was what was causing it :lol: (A bit of a tounge-twister)

// Edited my previous post to reflect the change
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

demonmaestro wrote:
I need all the machines to show as it is part of a future expansion of the project.

now the ultra hot/hot/regular it needs to be like that because ultrahot bits need to go on first and what ever is up top will go on next to the machine.

so ultrahot bits are hotter than hot bits
hot bits are hotter than regular bits

all need to be ordered by there bitdate unless ultrahot/hot status

That's why I suggest to change the database structure the way I suggested previously. Instead of having 'ultrahot' and 'hot' columns, you'll have only one column 'temperature' with 1 for ultrahot, 2 for hot and 3 for regular. Then you'll 'ORDER BY bits.temperature AND bits.bitdate ASC' (pretty sure you could order 2 fields) and you have what you want. Current way you have is inefficient.
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

Okay. Well I will make the change in the DB now.
Thats going to throw this out of wack i am sure.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

demonmaestro wrote:
Okay. Well I will make the change in the DB now.
Thats going to throw this out of wack i am sure.

:lol: Yes, we'll have to come up with different code to read the database. If you want you can wait for ScottG, maybe he'll come up with a solution for the way you have it at the moment... just that it's above me right now, and too tired to brainstorm a solution.

Only way I can think of doing it this way right now is by making 3 separate calls to the database.
Code: [ Select ]
SELECT ... FROM ... WHERE ultrahot = 1 ORDER BY ...

while(...)
{

}

SELECT ... FROM ... WHERE hot = 1 ORDER BY ...

while(...)
{

}

SELECT ... FROM ... WHERE ultrahot = 0 AND hot = 0 ORDER BY ...

while(...)
{

}
  1. SELECT ... FROM ... WHERE ultrahot = 1 ORDER BY ...
  2. while(...)
  3. {
  4. }
  5. SELECT ... FROM ... WHERE hot = 1 ORDER BY ...
  6. while(...)
  7. {
  8. }
  9. SELECT ... FROM ... WHERE ultrahot = 0 AND hot = 0 ORDER BY ...
  10. while(...)
  11. {
  12. }
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

The order should be built in with

PHP Code: [ Select ]
// Build the ultra hot table
                    if(isset($table_row[$type]['ultrahot']))
                    {
                        $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
                    }
                   
                    // Build the hot table
                    if(isset($table_row[$type]['hot']))
                    {
                        $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
                    }
 
                    // Build the normal table
                    if(isset($table_row[$type]['status']))
                    {
                        $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
                    }
 
  1. // Build the ultra hot table
  2.                     if(isset($table_row[$type]['ultrahot']))
  3.                     {
  4.                         $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
  5.                     }
  6.                    
  7.                     // Build the hot table
  8.                     if(isset($table_row[$type]['hot']))
  9.                     {
  10.                         $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
  11.                     }
  12.  
  13.                     // Build the normal table
  14.                     if(isset($table_row[$type]['status']))
  15.                     {
  16.                         $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
  17.                     }
  18.  


Since your looping by row then build each column, in each column is a table per bit that's also why i didn't use numbers when setting temps so there is an entry on normal

this also help to sort it
PHP Code: [ Select ]
 // Sort by temperature starting with ultrahot
   if($row['ultrahot']) {
      $table[$row['name']][$on_machine]['ultrahot'] = $row;
   } else if($row['hot']) {
      $table[$row['name']][$on_machine]['hot'] = $row;
   } else {
      $table[$row['name']][$on_machine]['normal'] = $row;
   }
  1.  // Sort by temperature starting with ultrahot
  2.    if($row['ultrahot']) {
  3.       $table[$row['name']][$on_machine]['ultrahot'] = $row;
  4.    } else if($row['hot']) {
  5.       $table[$row['name']][$on_machine]['hot'] = $row;
  6.    } else {
  7.       $table[$row['name']][$on_machine]['normal'] = $row;
  8.    }
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

ScottG wrote:
The order should be built in with

PHP Code: [ Select ]
// Build the ultra hot table
                    if(isset($table_row[$type]['ultrahot']))
                    {
                        $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
                    }
                   
                    // Build the hot table
                    if(isset($table_row[$type]['hot']))
                    {
                        $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
                    }
 
                    // Build the normal table
                    if(isset($table_row[$type]['status']))
                    {
                        $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
                    }
 
  1. // Build the ultra hot table
  2.                     if(isset($table_row[$type]['ultrahot']))
  3.                     {
  4.                         $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
  5.                     }
  6.                    
  7.                     // Build the hot table
  8.                     if(isset($table_row[$type]['hot']))
  9.                     {
  10.                         $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
  11.                     }
  12.  
  13.                     // Build the normal table
  14.                     if(isset($table_row[$type]['status']))
  15.                     {
  16.                         $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
  17.                     }
  18.  


Since your looping by row then build each column, in each column is a table per bit that's also why i didn't use numbers when setting temps so there is an entry on normal

this also help to sort it
PHP Code: [ Select ]
 // Sort by temperature starting with ultrahot
   if($row['ultrahot']) {
      $table[$row['name']][$on_machine]['ultrahot'] = $row;
   } else if($row['hot']) {
      $table[$row['name']][$on_machine]['hot'] = $row;
   } else {
      $table[$row['name']][$on_machine]['normal'] = $row;
   }
  1.  // Sort by temperature starting with ultrahot
  2.    if($row['ultrahot']) {
  3.       $table[$row['name']][$on_machine]['ultrahot'] = $row;
  4.    } else if($row['hot']) {
  5.       $table[$row['name']][$on_machine]['hot'] = $row;
  6.    } else {
  7.       $table[$row['name']][$on_machine]['normal'] = $row;
  8.    }

That wouldn't (and doesn't) create the order. I tested it... it just creates it from what it gets in the array. Consider the following array.
Code: [ Select ]
Array
(
  [DMG 2] => Array
    (
      [0] => Array
        (
          [1] => Array
            (
              [status] => Array
                (
                  [machine] => DMG 2
                  [id] => 21
                  [serial] => T7040968
                  [crown] => T588X19681
                  [type] => SLIM
                  [size] => 8.75
                  [status] => DMG 2
                  [load_wk] => 13
                  [hot] => 0
                  [ultrahot] => 0
                  [bitdate] => 16-Apr
                  [onmachine] => 1
                )

            )

        )

      [1] => Array
        (
          [0] => Array
            (
              [status] => Array
                (
                  [machine] => DMG 2
                  [id] => 44
                  [serial] => T7040983
                  [crown] => T588X20618
                  [type] => STEEL
                  [size] => 12.25
                  [status] => DMG 2
                  [load_wk] => 13
                  [hot] => 1
                  [ultrahot] => 0
                  [bitdate] => 3-May
                  [onmachine] => 1
                )

            )

        )

      [2] => Array
        (
          [0] => Array
            (
              [status] => Array
                (
                  [machine] => DMG 2
                  [id] => 56
                  [serial] => T7040986
                  [crown] => T588S11111
                  [type] => STEEL
                  [size] => 12.25
                  [status] => DMG 2
                  [load_wk] => 13
                  [hot] => 0
                  [ultrahot] => 0
                  [bitdate] => 3-May
                  [onmachine] => 1
                )

            )

        )

      [3] => Array
        (
          [1] => Array
            (
              [ultrahot] => Array
                (
                  [machine] => DMG 2
                  [id] => 102
                  [serial] => T7040916
                  [crown] => T588X18821
                  [type] => SLIM
                  [size] => 8.5
                  [status] => DMG 2
                  [load_wk] => 12
                  [hot] => 0
                  [ultrahot] => 1
                  [bitdate] => 12-Apr
                  [onmachine] => 1
                )

            )

        )

    )
)
  1. Array
  2. (
  3.   [DMG 2] => Array
  4.     (
  5.       [0] => Array
  6.         (
  7.           [1] => Array
  8.             (
  9.               [status] => Array
  10.                 (
  11.                   [machine] => DMG 2
  12.                   [id] => 21
  13.                   [serial] => T7040968
  14.                   [crown] => T588X19681
  15.                   [type] => SLIM
  16.                   [size] => 8.75
  17.                   [status] => DMG 2
  18.                   [load_wk] => 13
  19.                   [hot] => 0
  20.                   [ultrahot] => 0
  21.                   [bitdate] => 16-Apr
  22.                   [onmachine] => 1
  23.                 )
  24.             )
  25.         )
  26.       [1] => Array
  27.         (
  28.           [0] => Array
  29.             (
  30.               [status] => Array
  31.                 (
  32.                   [machine] => DMG 2
  33.                   [id] => 44
  34.                   [serial] => T7040983
  35.                   [crown] => T588X20618
  36.                   [type] => STEEL
  37.                   [size] => 12.25
  38.                   [status] => DMG 2
  39.                   [load_wk] => 13
  40.                   [hot] => 1
  41.                   [ultrahot] => 0
  42.                   [bitdate] => 3-May
  43.                   [onmachine] => 1
  44.                 )
  45.             )
  46.         )
  47.       [2] => Array
  48.         (
  49.           [0] => Array
  50.             (
  51.               [status] => Array
  52.                 (
  53.                   [machine] => DMG 2
  54.                   [id] => 56
  55.                   [serial] => T7040986
  56.                   [crown] => T588S11111
  57.                   [type] => STEEL
  58.                   [size] => 12.25
  59.                   [status] => DMG 2
  60.                   [load_wk] => 13
  61.                   [hot] => 0
  62.                   [ultrahot] => 0
  63.                   [bitdate] => 3-May
  64.                   [onmachine] => 1
  65.                 )
  66.             )
  67.         )
  68.       [3] => Array
  69.         (
  70.           [1] => Array
  71.             (
  72.               [ultrahot] => Array
  73.                 (
  74.                   [machine] => DMG 2
  75.                   [id] => 102
  76.                   [serial] => T7040916
  77.                   [crown] => T588X18821
  78.                   [type] => SLIM
  79.                   [size] => 8.5
  80.                   [status] => DMG 2
  81.                   [load_wk] => 12
  82.                   [hot] => 0
  83.                   [ultrahot] => 1
  84.                   [bitdate] => 12-Apr
  85.                   [onmachine] => 1
  86.                 )
  87.             )
  88.         )
  89.     )
  90. )

The last one is ultrahot, 3rd is normal, 2nd is hot and 1st is normal. That loop is going to create them in the order that it receives them... and display as such.

With that array, you are going to have a normal on top, then hot, then normal again and then ultrahot. Array was derived from the database with that script (it's the outcome I got from that script).
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

im not going to touch the DB till something get figured out :lol:
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

ok what about adding to the query

ORDER BY ultrahot DESC, last_hot DESC;

my mind is frying out and i'm still using my phone
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

ScottG wrote:
ok what about adding to the query

ORDER BY ultrahot DESC, last_hot DESC;

my mind is frying out and i'm still using my phone



I can tell you even got 404 posts.. :lol:
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

ScottG wrote:
ok what about adding to the query

ORDER BY ultrahot DESC, last_hot DESC;

my mind is frying out and i'm still using my phone

Oh, didn't know that's how you combine ORDER by fields. That did fix it.

I've tried
SQL Code: [ Select ]
SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.STATUS ORDER BY bits.ultrahot, bits.hot DESC

And that failed... guess I didn't know the proper syntax to do it.

The proper SQL to use is.
SQL Code: [ Select ]
[sql]SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.STATUS ORDER BY bits.ultrahot DESC, bits.hot DESC, bits.bitdate ASC
(I also included the bitdate ASC order).
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

it appears to be it but it took the machines out of order now...

ha...

//edit added BitMachine.id ASC to the beginning of the ORDER BY
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

SQL Code: [ Select ]
SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.STATUS ORDER BY BitMachine.machine ASC,  bits.ultrahot DESC, bits.hot DESC, bits.bitdate ASC


// edit... didn't see your edit :lol:
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

so far that appears to be great.

Although i had notice that while it can show more than one bit in the machine. Truly only one but can be ran at a time per machine. So there is no need to have the scroll box on the In Machine row
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

line 160
PHP Code: [ Select ]
if($type) { $return[] = tab(4) . '<div style="overflow:auto; height:200px; width:110px;">'; }


line 192

PHP Code: [ Select ]
if($type) { $return[] = tab(4) . '</div>'; }


all together now
PHP Code: [ Select ]
// This function will build and return the table row
function build_row($keys, $rows, $type)
{
   
    // Add return array we must.
    $return = array();
 
    // What type it is do we know. Hmmmm, yes.
    switch($type)
    {
        case '1':
            $text = 'In Machine';
            break;
        case '0':
            $text = 'Machine Que';
            break;
    }
   
    // Loop through the table keys to build the columns
    foreach($keys as $value)
    {
        // Start the output
        $return[] = tab(3) . '<td align="center">';
        $return[] = tab(4) . $text;
        if($type) { $return[] = tab(4) . '<div style="overflow:auto; height:200px; width:110px;">'; }
       
        // Make sure we have an array
        if(isset($rows[$value]))
        {
            // Loop through the values that are in the on machine row of the table
            foreach($rows[$value] as $key => $table_row)
            {
                // Check for NULL
                if(isset($table_row[$type]))
                {
                    // Build the ultra hot table
                    if(isset($table_row[$type]['ultrahot']))
                    {
                        $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
                    }
                   
                    // Build the hot table
                    if(isset($table_row[$type]['hot']))
                    {
                        $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
                    }
 
                    // Build the normal table
                    if(isset($table_row[$type]['status']))
                    {
                        $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
                    }
                }
            }
        }
 
        if($type) { $return[] = tab(4) . '</div>'; }
        $return[] = tab(3) . '</td>';
 
    }
   
    // Join and return the output
    return implode(hs(), $return);
}
 
  1. // This function will build and return the table row
  2. function build_row($keys, $rows, $type)
  3. {
  4.    
  5.     // Add return array we must.
  6.     $return = array();
  7.  
  8.     // What type it is do we know. Hmmmm, yes.
  9.     switch($type)
  10.     {
  11.         case '1':
  12.             $text = 'In Machine';
  13.             break;
  14.         case '0':
  15.             $text = 'Machine Que';
  16.             break;
  17.     }
  18.    
  19.     // Loop through the table keys to build the columns
  20.     foreach($keys as $value)
  21.     {
  22.         // Start the output
  23.         $return[] = tab(3) . '<td align="center">';
  24.         $return[] = tab(4) . $text;
  25.         if($type) { $return[] = tab(4) . '<div style="overflow:auto; height:200px; width:110px;">'; }
  26.        
  27.         // Make sure we have an array
  28.         if(isset($rows[$value]))
  29.         {
  30.             // Loop through the values that are in the on machine row of the table
  31.             foreach($rows[$value] as $key => $table_row)
  32.             {
  33.                 // Check for NULL
  34.                 if(isset($table_row[$type]))
  35.                 {
  36.                     // Build the ultra hot table
  37.                     if(isset($table_row[$type]['ultrahot']))
  38.                     {
  39.                         $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
  40.                     }
  41.                    
  42.                     // Build the hot table
  43.                     if(isset($table_row[$type]['hot']))
  44.                     {
  45.                         $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
  46.                     }
  47.  
  48.                     // Build the normal table
  49.                     if(isset($table_row[$type]['status']))
  50.                     {
  51.                         $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
  52.                     }
  53.                 }
  54.             }
  55.         }
  56.  
  57.         if($type) { $return[] = tab(4) . '</div>'; }
  58.         $return[] = tab(3) . '</td>';
  59.  
  60.     }
  61.    
  62.     // Join and return the output
  63.     return implode(hs(), $return);
  64. }
  65.  


EDIT missed a }
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

thats not working captin
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

Well, if you're ever going to have only one there, then you won't see the scroll bar even if it's coded in there anyway. I wouldn't worry about it.
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

its not that i am worring about it as the height. but i maybe can do that from the table specs and not the div height
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

The div height controls the scroll you could set a class variable in the switch that test the in and que of the machine that would set the height and overflow on the div
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

well couldn't I just do it from the <td> ?
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

I can't think in css right now lol. what was not working about that last part?
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 679
  • Loc: Conroe, Texas

Post 3+ Months Ago

changing the div. it made all the info disapear.

PHP Code: [ Select ]
<?php
 
// Initialize
require_once('data.php');
 
 
// These are functions to help make the code nicer and easier to read and by all means not required
// This function is just to make code pretty and returns tabs '\t'. This function relies on the repeat_string function
function tab($number = 1)
{
    // Call repeat_string and return the tabs
    return repeat_string("\t", $number);
}
 
// This function is just to make code pretty and returns hard spaces '\r\n'. This function relies on the repeat_string function
function hs($number = 1)
{
    // Call repeat_string and return the tabs
    return repeat_string("\r\n", $number);
}
 
// This function will build a string with a certain number of repeats. Example \r\n\r\n
function repeat_string($type, $number = 1)
{
   
    // Make a return var
    $return = array();
 
    // Loop the number
    for($i=0; $i < $number; $i++)
    {
        // Add the tab
        $return[] = $type;
    }
 
    // Return the hard space
    return implode('', $return);
   
}
 
// This function is a pretty vardump
function pd($input)
{
    echo '<pre>'; var_dump($input); echo '</pre>';  
}
// The functions above are to help make the code nicer and easier to read and by all means not required.
 
 
 
// This function will build out the inner table for all cases
function build_table($row, $type, $temp)
{
    if(empty($row['id']))
    {
        return;
    }
 
    // Create an array to hold the table
    $return = array();
   
    // Setup the surrounding div tag to properly color the table
    switch($type)
    {
        case 'STEEL':
            $return[] = tab(5) .'<div style="background-color:#FF9999;">';
            break;
        case 'SLIM':
            $return[] = tab(5) .'<div style="background-color:#9999FF;">';
            break;
        case 'KYMERA':
            $return[] = tab(5) .'<div style="background-color:#FF2626;">';
            break;
        case 'HYBRID':
            $return[] = tab(5) .'<div style="background-color:#FF2626;">';
            break;
        case 'EZC':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        case 'RWD':
            $return[] = tab(5) .'<div style="background-color:#FF9326;">';
            break;
        case 'EZR':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        case 'EZB':
            $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
            break;
        default:
            $return[] = tab(5) .'<div>';
    }
   
    // Start building the output
    $return[] = tab(6) .'<a href="operator.php?id='. $row['serial'] .'">';
    $return[] = tab(7) .'<div style="border:solid; border-color:#000000;">';
    $return[] = tab(8) .'<table border="0" cellspacing="0" cellpadding="0" width="100%">';
   
   // Take their temperature and add to the output if their temperature matches
    switch($temp)
    {
        case 'ultrahot':
            $return[] = tab(9) .'<tr>';
            $return[] = tab(10) .'<td>';
            $return[] = tab(11) .'<div style="background-color:#FF0000;">*Ultra Hot*</div>';
            $return[] = tab(10) .'</td>';
            $return[] = tab(9) .'</tr>';
            break;
 
        case 'hot':
            $return[] = tab(9) .'<tr>';
            $return[] = tab(10) .'<td>';
            $return[] = tab(11) .'<div style="background-color:#FF0000;">*HOT*</div>';
            $return[] = tab(10) .'</td>';
            $return[] = tab(9) .'</tr>';
            break;
    }
   
    // Finish building the output
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='. $row['serial'].'">'. $row['serial'] .'</a>&nbsp;<a href="operator.php?id='.$row['serial'].'">'. $row['load_wk'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['crown'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
    $return[] = tab(9) .'<tr>';
    $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['size'] .'</a></td>';
    $return[] = tab(9) .'</tr>';
    $return[] = tab(8) .'</table>';
    $return[] = tab(7) .'</div>';
    $return[] = tab(6) .'</a>';
    $return[] = tab(5) .'</div>';
 
    // Join and return the output
    return implode(hs(), $return);
}
 
// This function will build and return the table row
function build_row($keys, $rows, $type)
{
   
    // Add return array we must.
    $return = array();
 
    // What type it is do we know. Hmmmm, yes.
    switch($type)
    {
        case '1':
            $text = 'In Machine';
            break;
        case '0':
            $text = 'Machine Que';
            break;
    }
   
    // Loop through the table keys to build the columns
    foreach($keys as $value)
    {
        // Start the output
        $return[] = tab(3) . '<td align="center">';
        $return[] = tab(4) . $text;
        $return[] = tab(4) . '<div style="overflow:auto; width:110px;">';
       
        // Make sure we have an array
        if(isset($rows[$value]))
        {
            // Loop through the values that are in the on machine row of the table
            foreach($rows[$value] as $key => $table_row)
            {
                // Check for NULL
                if(isset($table_row[$type]))
                {
                    // Build the ultra hot table
                    if(isset($table_row[$type]['ultrahot']))
                    {
                        $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
                    }
                   
                    // Build the hot table
                    if(isset($table_row[$type]['hot']))
                    {
                        $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
                    }
 
                    // Build the normal table
                    if(isset($table_row[$type]['status']))
                    {
                        $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
                    }
                }
            }
        }
 
        $return[] = tab(4) . '</div>';
        $return[] = tab(3) . '</td>';
 
    }
   
    // Join and return the output
    return implode(hs(), $return);
}
         
// Set SQL Query
$query = "SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.STATUS ORDER BY BitMachine.id ASC, bits.ultrahot DESC, bits.hot DESC, bits.bitdate ASC";
 
// Execute
$results_key = mysql_query($query) or die(mysql_error());
 
// Make the arrays to hold the table info
$table      = array();
$table_keys = array();
 
// Loop the results
while($row = mysql_fetch_assoc($results_key))
{
   
    // Set the table header
    $table_keys[] = $row['machine'];
 
    // Check to see if this bit is on the machine.
    $on_machine = ($row['onmachine']) ? '1' : '0';
 
    // Sort by temperature starting with ultrahot
    if($row['ultrahot'])
    {
        $table[$row['machine']][][$on_machine]['ultrahot'] = $row;
    }
    elseif($row['hot'])
    {
        $table[$row['machine']][][$on_machine]['hot'] = $row;
    }
    else
    {
        $table[$row['machine']][][$on_machine]['status'] = $row;
    }
}
 
$table_keys = array_unique($table_keys);
 
?>
 
<div style="overflow:auto; width:100%; height:100%">
    <table border="1" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
        <tr>
            <td align="center"><?php echo implode('</td><td align="center">', $table_keys); ?></td>
        </tr>
        <tr>
            <?php echo build_row($table_keys, $table, '1'); ?>
        </tr>
        <tr>
            <?php echo build_row($table_keys, $table, '0'); ?>
        </tr>
    </table>
</div>
 
  1. <?php
  2.  
  3. // Initialize
  4. require_once('data.php');
  5.  
  6.  
  7. // These are functions to help make the code nicer and easier to read and by all means not required
  8. // This function is just to make code pretty and returns tabs '\t'. This function relies on the repeat_string function
  9. function tab($number = 1)
  10. {
  11.     // Call repeat_string and return the tabs
  12.     return repeat_string("\t", $number);
  13. }
  14.  
  15. // This function is just to make code pretty and returns hard spaces '\r\n'. This function relies on the repeat_string function
  16. function hs($number = 1)
  17. {
  18.     // Call repeat_string and return the tabs
  19.     return repeat_string("\r\n", $number);
  20. }
  21.  
  22. // This function will build a string with a certain number of repeats. Example \r\n\r\n
  23. function repeat_string($type, $number = 1)
  24. {
  25.    
  26.     // Make a return var
  27.     $return = array();
  28.  
  29.     // Loop the number
  30.     for($i=0; $i < $number; $i++)
  31.     {
  32.         // Add the tab
  33.         $return[] = $type;
  34.     }
  35.  
  36.     // Return the hard space
  37.     return implode('', $return);
  38.    
  39. }
  40.  
  41. // This function is a pretty vardump
  42. function pd($input)
  43. {
  44.     echo '<pre>'; var_dump($input); echo '</pre>';  
  45. }
  46. // The functions above are to help make the code nicer and easier to read and by all means not required.
  47.  
  48.  
  49.  
  50. // This function will build out the inner table for all cases
  51. function build_table($row, $type, $temp)
  52. {
  53.     if(empty($row['id']))
  54.     {
  55.         return;
  56.     }
  57.  
  58.     // Create an array to hold the table
  59.     $return = array();
  60.    
  61.     // Setup the surrounding div tag to properly color the table
  62.     switch($type)
  63.     {
  64.         case 'STEEL':
  65.             $return[] = tab(5) .'<div style="background-color:#FF9999;">';
  66.             break;
  67.         case 'SLIM':
  68.             $return[] = tab(5) .'<div style="background-color:#9999FF;">';
  69.             break;
  70.         case 'KYMERA':
  71.             $return[] = tab(5) .'<div style="background-color:#FF2626;">';
  72.             break;
  73.         case 'HYBRID':
  74.             $return[] = tab(5) .'<div style="background-color:#FF2626;">';
  75.             break;
  76.         case 'EZC':
  77.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  78.             break;
  79.         case 'RWD':
  80.             $return[] = tab(5) .'<div style="background-color:#FF9326;">';
  81.             break;
  82.         case 'EZR':
  83.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  84.             break;
  85.         case 'EZB':
  86.             $return[] = tab(5) .'<div style="background-color:#FFFF26;">';
  87.             break;
  88.         default:
  89.             $return[] = tab(5) .'<div>';
  90.     }
  91.    
  92.     // Start building the output
  93.     $return[] = tab(6) .'<a href="operator.php?id='. $row['serial'] .'">';
  94.     $return[] = tab(7) .'<div style="border:solid; border-color:#000000;">';
  95.     $return[] = tab(8) .'<table border="0" cellspacing="0" cellpadding="0" width="100%">';
  96.    
  97.    // Take their temperature and add to the output if their temperature matches
  98.     switch($temp)
  99.     {
  100.         case 'ultrahot':
  101.             $return[] = tab(9) .'<tr>';
  102.             $return[] = tab(10) .'<td>';
  103.             $return[] = tab(11) .'<div style="background-color:#FF0000;">*Ultra Hot*</div>';
  104.             $return[] = tab(10) .'</td>';
  105.             $return[] = tab(9) .'</tr>';
  106.             break;
  107.  
  108.         case 'hot':
  109.             $return[] = tab(9) .'<tr>';
  110.             $return[] = tab(10) .'<td>';
  111.             $return[] = tab(11) .'<div style="background-color:#FF0000;">*HOT*</div>';
  112.             $return[] = tab(10) .'</td>';
  113.             $return[] = tab(9) .'</tr>';
  114.             break;
  115.     }
  116.    
  117.     // Finish building the output
  118.     $return[] = tab(9) .'<tr>';
  119.     $return[] = tab(10) .'<td><a href="operator.php?id='. $row['serial'].'">'. $row['serial'] .'</a>&nbsp;<a href="operator.php?id='.$row['serial'].'">'. $row['load_wk'] .'</a></td>';
  120.     $return[] = tab(9) .'</tr>';
  121.     $return[] = tab(9) .'<tr>';
  122.     $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['crown'] .'</a></td>';
  123.     $return[] = tab(9) .'</tr>';
  124.     $return[] = tab(9) .'<tr>';
  125.     $return[] = tab(10) .'<td><a href="operator.php?id='.$row['serial'].'">'. $row['size'] .'</a></td>';
  126.     $return[] = tab(9) .'</tr>';
  127.     $return[] = tab(8) .'</table>';
  128.     $return[] = tab(7) .'</div>';
  129.     $return[] = tab(6) .'</a>';
  130.     $return[] = tab(5) .'</div>';
  131.  
  132.     // Join and return the output
  133.     return implode(hs(), $return);
  134. }
  135.  
  136. // This function will build and return the table row
  137. function build_row($keys, $rows, $type)
  138. {
  139.    
  140.     // Add return array we must.
  141.     $return = array();
  142.  
  143.     // What type it is do we know. Hmmmm, yes.
  144.     switch($type)
  145.     {
  146.         case '1':
  147.             $text = 'In Machine';
  148.             break;
  149.         case '0':
  150.             $text = 'Machine Que';
  151.             break;
  152.     }
  153.    
  154.     // Loop through the table keys to build the columns
  155.     foreach($keys as $value)
  156.     {
  157.         // Start the output
  158.         $return[] = tab(3) . '<td align="center">';
  159.         $return[] = tab(4) . $text;
  160.         $return[] = tab(4) . '<div style="overflow:auto; width:110px;">';
  161.        
  162.         // Make sure we have an array
  163.         if(isset($rows[$value]))
  164.         {
  165.             // Loop through the values that are in the on machine row of the table
  166.             foreach($rows[$value] as $key => $table_row)
  167.             {
  168.                 // Check for NULL
  169.                 if(isset($table_row[$type]))
  170.                 {
  171.                     // Build the ultra hot table
  172.                     if(isset($table_row[$type]['ultrahot']))
  173.                     {
  174.                         $return[] = build_table($table_row[$type]['ultrahot'], $table_row[$type]['ultrahot']['type'], 'ultrahot');
  175.                     }
  176.                    
  177.                     // Build the hot table
  178.                     if(isset($table_row[$type]['hot']))
  179.                     {
  180.                         $return[] = build_table($table_row[$type]['hot'], $table_row[$type]['hot']['type'], 'hot');
  181.                     }
  182.  
  183.                     // Build the normal table
  184.                     if(isset($table_row[$type]['status']))
  185.                     {
  186.                         $return[] = build_table($table_row[$type]['status'], $table_row[$type]['status']['type'], 'status');
  187.                     }
  188.                 }
  189.             }
  190.         }
  191.  
  192.         $return[] = tab(4) . '</div>';
  193.         $return[] = tab(3) . '</td>';
  194.  
  195.     }
  196.    
  197.     // Join and return the output
  198.     return implode(hs(), $return);
  199. }
  200.          
  201. // Set SQL Query
  202. $query = "SELECT BitMachine.machine, bits.* FROM BitMachine LEFT JOIN bits ON BitMachine.machine = bits.STATUS ORDER BY BitMachine.id ASC, bits.ultrahot DESC, bits.hot DESC, bits.bitdate ASC";
  203.  
  204. // Execute
  205. $results_key = mysql_query($query) or die(mysql_error());
  206.  
  207. // Make the arrays to hold the table info
  208. $table      = array();
  209. $table_keys = array();
  210.  
  211. // Loop the results
  212. while($row = mysql_fetch_assoc($results_key))
  213. {
  214.    
  215.     // Set the table header
  216.     $table_keys[] = $row['machine'];
  217.  
  218.     // Check to see if this bit is on the machine.
  219.     $on_machine = ($row['onmachine']) ? '1' : '0';
  220.  
  221.     // Sort by temperature starting with ultrahot
  222.     if($row['ultrahot'])
  223.     {
  224.         $table[$row['machine']][][$on_machine]['ultrahot'] = $row;
  225.     }
  226.     elseif($row['hot'])
  227.     {
  228.         $table[$row['machine']][][$on_machine]['hot'] = $row;
  229.     }
  230.     else
  231.     {
  232.         $table[$row['machine']][][$on_machine]['status'] = $row;
  233.     }
  234. }
  235.  
  236. $table_keys = array_unique($table_keys);
  237.  
  238. ?>
  239.  
  240. <div style="overflow:auto; width:100%; height:100%">
  241.     <table border="1" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
  242.         <tr>
  243.             <td align="center"><?php echo implode('</td><td align="center">', $table_keys); ?></td>
  244.         </tr>
  245.         <tr>
  246.             <?php echo build_row($table_keys, $table, '1'); ?>
  247.         </tr>
  248.         <tr>
  249.             <?php echo build_row($table_keys, $table, '0'); ?>
  250.         </tr>
  251.     </table>
  252. </div>
  253.  

Post Information

  • Total Posts in this topic: 104 posts
  • Users browsing this forum: No registered users and 66 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.